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 UtcDaliToolkitTextlabelFastTextFitStressTest(void)
2094 ToolkitTestApplication application;
2095 tet_infoline(" UtcDaliToolkitTextlabelFastTextFitStressTest");
2096 TextLabel label = TextLabel::New();
2097 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
2098 label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2100 // connect to the text git changed signal.
2101 ConnectionTracker* testTracker = new ConnectionTracker();
2102 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2103 bool textFitChangedSignal = false;
2104 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2105 gTextFitChangedCallBackCalled = false;
2107 application.GetScene().Add(label);
2109 // check text label width at range [100, 299]
2110 for(int i=100; i<300; i++)
2112 Vector2 size((float)i, 200.f);
2113 label.SetProperty(Actor::Property::SIZE, size);
2115 // check point size with veryvery big range
2116 Property::Map textFitMapSet;
2117 textFitMapSet["enable"] = true;
2118 textFitMapSet["minSize"] = 10.f;
2119 textFitMapSet["maxSize"] = 10000.f;
2120 textFitMapSet["stepSize"] = -1.0f;
2121 textFitMapSet["fontSizeType"] = "pointSize";
2123 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2125 application.SendNotification();
2126 application.Render();
2129 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2130 DALI_TEST_CHECK(textFitChangedSignal);
2135 int UtcDaliToolkitTextlabelTextFitMultiLine(void)
2137 ToolkitTestApplication application;
2138 tet_infoline(" UtcDaliToolkitTextlabelTextFitMultiLine");
2139 TextLabel label = TextLabel::New();
2140 Vector2 size(500.0f, 100.0f);
2141 label.SetProperty(Actor::Property::SIZE, size);
2142 label.SetProperty(TextLabel::Property::TEXT, "Hello world\nHello world");
2143 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2145 // connect to the text git changed signal.
2146 ConnectionTracker* testTracker = new ConnectionTracker();
2147 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2148 bool textFitChangedSignal = false;
2149 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2150 gTextFitChangedCallBackCalled = false;
2152 Property::Map textFitMapSet;
2153 textFitMapSet["enable"] = true;
2154 textFitMapSet["minSize"] = 10.f;
2155 textFitMapSet["maxSize"] = 100.f;
2156 textFitMapSet["stepSize"] = -1.0f;
2157 textFitMapSet["fontSizeType"] = "pointSize";
2159 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2160 label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2162 application.GetScene().Add(label);
2164 application.SendNotification();
2165 application.Render();
2167 float textFitFontSize = (label.GetProperty(Dali::Toolkit::DevelTextLabel::Property::TEXT_FIT).Get<Property::Map>())["fontSize"].Get<float>();
2168 DALI_TEST_EQUALS(textFitFontSize, 14.f, TEST_LOCATION);
2170 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2171 DALI_TEST_CHECK(textFitChangedSignal);
2176 int UtcDaliToolkitTextlabelTextFitArray(void)
2178 ToolkitTestApplication application;
2179 tet_infoline(" UtcDaliToolkitTextlabelTextFitArray");
2180 TextLabel label = TextLabel::New();
2181 Vector2 size(300.0f, 80.0f);
2182 label.SetProperty(Actor::Property::SIZE, size);
2183 label.SetProperty(TextLabel::Property::TEXT, "A Quick Brown Fox Jumps Over The Lazy Dog");
2184 label.SetProperty(DevelTextLabel::Property::MIN_LINE_SIZE, 80.f);
2185 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
2186 application.GetScene().Add(label);
2188 // make sorted options.
2189 std::vector<DevelTextLabel::FitOption> fitOptions;
2190 fitOptions.push_back(DevelTextLabel::FitOption(10, 12));
2191 fitOptions.push_back(DevelTextLabel::FitOption(8, 10));
2192 fitOptions.push_back(DevelTextLabel::FitOption(6, 8));
2193 fitOptions.push_back(DevelTextLabel::FitOption(4, 6));
2194 fitOptions.push_back(DevelTextLabel::FitOption(20, 22));
2195 fitOptions.push_back(DevelTextLabel::FitOption(22, 24));
2196 fitOptions.push_back(DevelTextLabel::FitOption(12, 14));
2198 DevelTextLabel::SetTextFitArray(label, true, fitOptions);
2200 application.SendNotification();
2201 application.Render();
2203 bool enable = Dali::Toolkit::DevelTextLabel::IsTextFitArrayEnabled(label);
2204 DALI_TEST_EQUALS(true, enable, TEST_LOCATION);
2206 std::vector<Dali::Toolkit::DevelTextLabel::FitOption> getFitOptions = Dali::Toolkit::DevelTextLabel::GetTextFitArray(label);
2207 size_t numberOfFitOptions = getFitOptions.size();
2208 DALI_TEST_EQUALS(7u, numberOfFitOptions, TEST_LOCATION);
2210 const Vector3 EXPECTED_NATURAL_SIZE(276.0f, 16.0f, 0.0f);
2211 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2213 std::vector<DevelTextLabel::FitOption> emptyFitOptions;
2214 DevelTextLabel::SetTextFitArray(label, false, emptyFitOptions);
2216 application.SendNotification();
2217 application.Render();
2219 enable = Dali::Toolkit::DevelTextLabel::IsTextFitArrayEnabled(label);
2220 DALI_TEST_EQUALS(false, enable, TEST_LOCATION);
2222 const Vector3 EXPECTED_NATURAL_SIZE_DISABLE(690.0f, 80.0f, 0.0f);
2223 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE_DISABLE, label.GetNaturalSize(), TEST_LOCATION);
2225 // make unsorted options.
2226 std::vector<DevelTextLabel::FitOption> unorderedFitOptions;
2227 unorderedFitOptions.push_back(DevelTextLabel::FitOption(4, 6));
2228 unorderedFitOptions.push_back(DevelTextLabel::FitOption(6, 8));
2229 unorderedFitOptions.push_back(DevelTextLabel::FitOption(8, 10));
2230 unorderedFitOptions.push_back(DevelTextLabel::FitOption(10, 8));
2232 DevelTextLabel::SetTextFitArray(label, true, unorderedFitOptions);
2234 application.SendNotification();
2235 application.Render();
2237 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2242 int UtcDaliToolkitTextlabelMaxTextureSet(void)
2244 ToolkitTestApplication application;
2245 tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
2247 DevelText::BitmapFontDescription fontDescription;
2248 fontDescription.name = "Digits";
2249 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f});
2251 TextAbstraction::BitmapFont bitmapFont;
2252 DevelText::CreateBitmapFont(fontDescription, bitmapFont);
2254 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2255 fontClient.GetFontId(bitmapFont);
2257 TextLabel label = TextLabel::New();
2258 label.SetProperty(TextLabel::Property::FONT_FAMILY, "Digits");
2259 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2260 label.SetProperty(TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded.");
2261 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2262 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2264 Property::Map underlineMapSet;
2265 underlineMapSet.Clear();
2266 underlineMapSet.Insert("enable", true);
2267 underlineMapSet.Insert("color", Color::RED);
2268 underlineMapSet.Insert("height", 1);
2269 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2270 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2272 Property::Map strikethroughMapSet;
2273 strikethroughMapSet.Clear();
2274 strikethroughMapSet.Insert("enable", true);
2275 strikethroughMapSet.Insert("color", Color::RED);
2276 strikethroughMapSet.Insert("height", 2.0f);
2277 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2278 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2280 application.GetScene().Add(label);
2282 application.SendNotification();
2283 application.Render();
2285 const int maxTextureSize = Dali::GetMaxTextureSize();
2286 // Whether the rendered text is greater than maxTextureSize
2287 DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2289 // Check if the number of renderers is greater than 1.
2290 DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2293 underlineMapSet.Clear();
2294 underlineMapSet.Insert("enable", false);
2295 underlineMapSet.Insert("color", Color::BLUE);
2296 underlineMapSet.Insert("height", 0);
2297 underlineMapSet.Insert("type", Text::Underline::DASHED);
2298 underlineMapSet.Insert("dashWidth", 2);
2299 underlineMapSet.Insert("dashGap", 1);
2300 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2301 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2303 application.GetScene().Add(label);
2305 application.SendNotification();
2306 application.Render();
2308 // Whether the rendered text is greater than maxTextureSize
2309 DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2311 // Check if the number of renderers is greater than 1.
2312 DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2315 underlineMapSet.Clear();
2316 underlineMapSet.Insert("enable", false);
2317 underlineMapSet.Insert("color", Color::BLUE);
2318 underlineMapSet.Insert("height", 0);
2319 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
2320 underlineMapSet.Insert("dashWidth", 2);
2321 underlineMapSet.Insert("dashGap", 1);
2322 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2323 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2325 application.GetScene().Add(label);
2327 application.SendNotification();
2328 application.Render();
2330 // Whether the rendered text is greater than maxTextureSize
2331 DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2333 // Check if the number of renderers is greater than 1.
2334 DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2336 // Coverage test for case of layoutSize is bigger than maxTextureSize
2337 float max_value = static_cast<float>(std::numeric_limits<uint16_t>::max());
2338 label.SetProperty(Actor::Property::SIZE, Vector2(max_value, 30.0f));
2339 application.SendNotification();
2340 application.Render();
2345 int UtcDaliToolkitTextlabelStrikethroughExceedsWidthAndHeight(void)
2347 ToolkitTestApplication application;
2348 tet_infoline(" UtcDaliToolkitTextlabelStrikethroughExceedsWidthAndHeight");
2350 TextLabel label = TextLabel::New();
2351 label.SetProperty(TextLabel::Property::TEXT, "Test");
2352 label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2353 //Exeeding BufferWidth
2354 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 400.0f));
2355 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2356 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2358 application.GetScene().Add(label);
2359 application.SendNotification();
2360 application.Render();
2362 Property::Map strikethroughMapSet;
2363 strikethroughMapSet.Clear();
2364 strikethroughMapSet.Insert("enable", true);
2365 strikethroughMapSet.Insert("color", Color::BLUE);
2366 strikethroughMapSet.Insert("height", 2.0f);
2367 label.SetProperty(TextLabel::Property::TEXT, "Test1");
2368 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2369 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2370 application.GetScene().Add(label);
2371 application.SendNotification();
2372 application.Render();
2373 // Check if the number of renderers is 1.
2374 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2376 label = TextLabel::New();
2377 label.SetProperty(TextLabel::Property::TEXT, "Test");
2378 label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2380 //Exeeding BufferHeight
2381 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.0f));
2382 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2383 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2385 application.GetScene().Add(label);
2386 application.SendNotification();
2387 application.Render();
2389 strikethroughMapSet.Clear();
2390 strikethroughMapSet.Insert("enable", true);
2391 strikethroughMapSet.Insert("color", Color::BLUE);
2392 strikethroughMapSet.Insert("height", 2.0f);
2393 label.SetProperty(TextLabel::Property::TEXT, "Test2");
2394 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2395 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2396 application.GetScene().Add(label);
2397 application.SendNotification();
2398 application.Render();
2399 // Check if the number of renderers is 1.
2400 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2405 int UtcDaliToolkitTextlabelUnderlineExceedsWidth(void)
2407 ToolkitTestApplication application;
2408 tet_infoline(" UtcDaliToolkitTextlabelUnderlineExceedsWidth");
2410 TextLabel label = TextLabel::New();
2411 label.SetProperty(TextLabel::Property::TEXT, "Test");
2412 label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2413 //Exeeding BufferWidth
2414 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 400.0f));
2415 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2416 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2418 application.GetScene().Add(label);
2419 application.SendNotification();
2420 application.Render();
2422 Property::Map underlineMapSet;
2425 underlineMapSet.Clear();
2426 underlineMapSet.Insert("enable", true);
2427 underlineMapSet.Insert("color", Color::BLUE);
2428 underlineMapSet.Insert("height", 1);
2429 underlineMapSet.Insert("type", Text::Underline::SOLID);
2430 underlineMapSet.Insert("dashWidth", 2);
2431 underlineMapSet.Insert("dashGap", 1);
2432 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2433 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2435 application.GetScene().Add(label);
2437 application.SendNotification();
2438 application.Render();
2440 // Check if the number of renderers is 1.
2441 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2444 underlineMapSet.Clear();
2445 underlineMapSet.Insert("enable", true);
2446 underlineMapSet.Insert("color", Color::BLUE);
2447 underlineMapSet.Insert("height", 1);
2448 underlineMapSet.Insert("type", Text::Underline::DASHED);
2449 underlineMapSet.Insert("dashWidth", 2);
2450 underlineMapSet.Insert("dashGap", 1);
2451 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2452 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2454 application.GetScene().Add(label);
2456 application.SendNotification();
2457 application.Render();
2459 // Check if the number of renderers is 1.
2460 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2463 underlineMapSet.Clear();
2464 underlineMapSet.Insert("enable", true);
2465 underlineMapSet.Insert("color", Color::BLUE);
2466 underlineMapSet.Insert("height", 1);
2467 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
2468 underlineMapSet.Insert("dashWidth", 2);
2469 underlineMapSet.Insert("dashGap", 1);
2470 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2471 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2473 application.GetScene().Add(label);
2475 application.SendNotification();
2476 application.Render();
2478 // Check if the number of renderers is 1.
2479 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2484 int UtcDaliToolkitTextlabelLastCharacterIndex(void)
2486 ToolkitTestApplication application;
2487 tet_infoline(" UtcDaliToolkitTextlabelLastCharacterIndex");
2489 Vector2 size(300.0f, 100.0f);
2491 Dali::Toolkit::DevelText::RendererParameters textParameters;
2492 textParameters.text = "This is a sample text to get the last index.";
2493 textParameters.layout = "multiLine";
2494 textParameters.fontSize = 20.f;
2495 textParameters.textWidth = 300u;
2496 textParameters.textHeight = 100u;
2497 textParameters.ellipsisEnabled = true;
2498 Dali::Property::Array indexArray = Dali::Toolkit::DevelText::GetLastCharacterIndex(textParameters);
2500 DALI_TEST_CHECK(!indexArray.Empty());
2501 DALI_TEST_EQUALS(indexArray.GetElementAt(0).Get<int>(), 10, TEST_LOCATION);
2506 int UtcDaliToolkitTextlabelFontSizeScale(void)
2508 ToolkitTestApplication application;
2509 tet_infoline(" UtcDaliToolkitTextlabelFontSizeScale");
2511 TextLabel label = TextLabel::New();
2512 label.SetProperty(TextLabel::Property::POINT_SIZE, 30.f);
2513 label.SetProperty(TextLabel::Property::TEXT, "Test");
2514 Vector3 nonScaledSize = label.GetNaturalSize();
2516 TextLabel labelScaled = TextLabel::New();
2517 labelScaled.SetProperty(TextLabel::Property::POINT_SIZE, 15.f);
2518 labelScaled.SetProperty(Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f);
2519 labelScaled.SetProperty(TextLabel::Property::TEXT, "Test");
2520 Vector3 scaledSize = labelScaled.GetNaturalSize();
2522 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
2524 label.SetProperty(TextLabel::Property::PIXEL_SIZE, 30.f);
2525 label.SetProperty(TextLabel::Property::TEXT, "Test");
2526 nonScaledSize = label.GetNaturalSize();
2528 labelScaled.SetProperty(TextLabel::Property::PIXEL_SIZE, 15.f);
2529 labelScaled.SetProperty(Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f);
2530 labelScaled.SetProperty(TextLabel::Property::TEXT, "Test");
2531 scaledSize = labelScaled.GetNaturalSize();
2533 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
2538 int UtcDaliToolkitTextlabelAnchorColor(void)
2540 ToolkitTestApplication application;
2541 tet_infoline(" UtcDaliToolkitTextlabelAnchorColor");
2542 TextLabel label = TextLabel::New();
2543 DALI_TEST_CHECK(label);
2545 application.GetScene().Add(label);
2547 // connect to the anchor clicked signal.
2548 ConnectionTracker* testTracker = new ConnectionTracker();
2549 DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
2550 bool anchorClickedSignal = false;
2551 label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
2553 gAnchorClickedCallBackCalled = false;
2554 label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
2555 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2556 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2557 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2558 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2560 // Check that anchor color can be properly set
2561 label.SetProperty(DevelTextLabel::Property::ANCHOR_COLOR, Color::BLUE);
2562 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_COLOR), Color::BLUE, TEST_LOCATION);
2564 label.SetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR, Color::RED);
2565 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR), Color::RED, TEST_LOCATION);
2567 application.SendNotification();
2568 application.Render();
2570 // Create a tap event to touch the text label.
2571 TestGenerateTap(application, 5.0f, 25.0f, 100);
2572 application.SendNotification();
2573 application.Render();
2575 // Update clicked color
2576 label.SetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR, Color::BLUE);
2577 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR), Color::BLUE, TEST_LOCATION);
2579 application.SendNotification();
2580 application.Render();
2582 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2583 DALI_TEST_CHECK(anchorClickedSignal);
2588 // Positive test for the anchorClicked signal.
2589 int UtcDaliToolkitTextlabelAnchorClicked(void)
2591 ToolkitTestApplication application;
2592 tet_infoline(" UtcDaliToolkitTextlabelAnchorClicked");
2593 TextLabel label = TextLabel::New();
2594 DALI_TEST_CHECK(label);
2596 application.GetScene().Add(label);
2598 // connect to the anchor clicked signal.
2599 ConnectionTracker* testTracker = new ConnectionTracker();
2600 DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
2601 bool anchorClickedSignal = false;
2602 label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
2604 gAnchorClickedCallBackCalled = false;
2605 label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
2606 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2607 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2608 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2609 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2611 application.SendNotification();
2612 application.Render();
2614 // Create a tap event to touch the text label.
2615 TestGenerateTap(application, 5.0f, 25.0f, 100);
2616 application.SendNotification();
2617 application.Render();
2619 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2620 DALI_TEST_CHECK(anchorClickedSignal);
2623 gAnchorClickedCallBackCalled = false;
2624 anchorClickedSignal = false;
2625 label.SetProperty(TextLabel::Property::TEXT, "");
2626 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, false);
2628 application.SendNotification();
2629 application.Render();
2632 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2633 label.SetProperty(TextLabel::Property::TEXT, "<a color='red' clicked-color='green' href='https://www.tizen.org'>TIZEN</a>");
2634 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2635 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2636 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2638 application.SendNotification();
2639 application.Render();
2641 // Create a tap event to touch the text label.
2642 TestGenerateTap(application, 5.0f, 25.0f, 200);
2643 application.SendNotification();
2644 application.Render();
2646 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2647 DALI_TEST_CHECK(anchorClickedSignal);
2649 gAnchorClickedCallBackNotCalled = true;
2650 // Tap the outside of anchor, callback should not be called.
2651 TestGenerateTap(application, 150.f, 100.f, 300);
2652 application.SendNotification();
2653 application.Render();
2655 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
2660 int UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize(void)
2662 ToolkitTestApplication application;
2663 tet_infoline(" UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize ");
2665 //TextLabel is not using Atlas but this is to unify font-size on text-controllers
2667 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
2668 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
2669 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
2671 // Create a text editor
2672 TextLabel textLabel = TextLabel::New();
2673 //Set size to avoid automatic eliding
2674 textLabel.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
2675 //Set very large font-size using point-size
2676 textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 1000);
2677 //Specify font-family
2678 textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2679 //Set text to check if appear or not
2680 textLabel.SetProperty(TextLabel::Property::TEXT, "A");
2682 application.GetScene().Add(textLabel);
2684 application.SendNotification();
2685 application.Render();
2686 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
2687 Vector3 naturalSize = textLabel.GetNaturalSize();
2689 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
2690 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
2695 int UtcDaliTextLabelHyphenWrapMode(void)
2697 ToolkitTestApplication application;
2698 tet_infoline(" UtcDaliTextLabelHyphenWrapMode ");
2701 TextLabel label = TextLabel::New();
2702 label.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
2703 label.SetProperty(TextLabel::Property::POINT_SIZE, 12.f);
2704 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2705 application.GetScene().Add(label);
2706 application.SendNotification();
2707 application.Render();
2709 label.SetProperty(TextLabel::Property::TEXT, "Hi Experimen");
2710 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
2711 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::HYPHENATION), TEST_LOCATION);
2713 application.SendNotification();
2714 application.Render();
2716 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2722 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
2724 label.SetProperty(TextLabel::Property::TEXT, "Hi Experimen");
2725 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
2726 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::MIXED), TEST_LOCATION);
2728 application.SendNotification();
2729 application.Render();
2731 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2738 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
2743 int utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged(void)
2745 ToolkitTestApplication application;
2747 tet_infoline(" utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged ");
2749 int lineCountBefore = 0;
2750 int lineCountAfter = 0;
2752 // Create a text editor
2753 TextLabel textLabel = TextLabel::New();
2754 //Set very large font-size using point-size
2755 textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 10);
2756 //Specify font-family
2757 textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2759 textLabel.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.f));
2760 //Set text longer than width of textLabel
2761 textLabel.SetProperty(TextLabel::Property::TEXT, "Short text");
2762 //Set line wrap mode Character
2763 textLabel.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
2764 textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
2766 application.GetScene().Add(textLabel);
2768 application.SendNotification();
2769 application.Render();
2771 lineCountBefore = textLabel.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2773 textLabel.SetProperty(TextLabel::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
2774 lineCountAfter = textLabel.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2776 // When the text changed, the Line-count should be updated according to new text.
2777 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
2778 DALI_TEST_EQUALS(lineCountBefore, 1, TEST_LOCATION);
2779 DALI_TEST_GREATER(lineCountAfter, 1, TEST_LOCATION);
2784 int utcDaliTextLabelGeometryRTL(void)
2786 ToolkitTestApplication application;
2787 tet_infoline(" utcDaliTextLabelGeometryRTL");
2789 TextLabel label = TextLabel::New();
2790 DALI_TEST_CHECK(label);
2792 application.GetScene().Add(label);
2794 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2795 label.SetProperty(Actor::Property::SIZE, Vector2(150.f, 100.f));
2796 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2797 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2798 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2799 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2800 label.SetProperty(TextLabel::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر");
2801 // Avoid a crash when core load gl resources.
2802 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2804 // Render and notify
2805 application.SendNotification();
2806 application.Render();
2808 unsigned int expectedCount = 4;
2809 unsigned int startIndex = 3;
2810 unsigned int endIndex = 24;
2812 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2813 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2815 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2816 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2818 Vector<Vector2> expectedSizes;
2819 Vector<Vector2> expectedPositions;
2821 expectedPositions.PushBack(Vector2(25, 0));
2822 expectedSizes.PushBack(Vector2(34, 25));
2824 expectedPositions.PushBack(Vector2(-1, 25));
2825 expectedSizes.PushBack(Vector2(53, 25));
2827 expectedPositions.PushBack(Vector2(-1, 50));
2828 expectedSizes.PushBack(Vector2(60, 25));
2830 expectedPositions.PushBack(Vector2(75, 75));
2831 expectedSizes.PushBack(Vector2(37, 25));
2833 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2838 int utcDaliTextLabelGeometryGlyphMiddle(void)
2840 ToolkitTestApplication application;
2841 tet_infoline(" utcDaliTextLabelGeometryGlyphMiddle");
2843 TextLabel label = TextLabel::New();
2844 DALI_TEST_CHECK(label);
2846 application.GetScene().Add(label);
2848 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2849 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2850 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2851 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2852 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2853 label.SetProperty(TextLabel::Property::TEXT, "لا تحتوي على لا");
2855 // Avoid a crash when core load gl resources.
2856 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2858 // Render and notify
2859 application.SendNotification();
2860 application.Render();
2862 unsigned int expectedCount = 1;
2863 unsigned int startIndex = 1;
2864 unsigned int endIndex = 13;
2866 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2867 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2869 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2870 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2872 Vector<Vector2> expectedSizes;
2873 Vector<Vector2> expectedPositions;
2875 expectedPositions.PushBack(Vector2(6, 0));
2876 expectedSizes.PushBack(Vector2(125, 25));
2878 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2883 int utcDaliTextLabelGeometryOneGlyph(void)
2885 ToolkitTestApplication application;
2886 tet_infoline(" utcDaliTextLabelGeometryOneGlyph ");
2888 TextLabel label = TextLabel::New();
2889 DALI_TEST_CHECK(label);
2891 application.GetScene().Add(label);
2893 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2894 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2895 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2896 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2897 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2898 label.SetProperty(TextLabel::Property::TEXT, "H");
2900 // Avoid a crash when core load gl resources.
2901 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2903 // Render and notify
2904 application.SendNotification();
2905 application.Render();
2907 unsigned int expectedCount = 1;
2908 unsigned int startIndex = 0;
2909 unsigned int endIndex = 0;
2911 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2912 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2914 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2915 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2917 Vector<Vector2> expectedSizes;
2918 Vector<Vector2> expectedPositions;
2920 expectedPositions.PushBack(Vector2(-2, 0));
2921 expectedSizes.PushBack(Vector2(16, 25));
2923 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2925 positionsList.Clear();
2931 positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2932 sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2934 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2939 int utcDaliTextLabelGeometryNullPtr(void)
2941 ToolkitTestApplication application;
2942 tet_infoline("utcDaliTextLabelGeometryNullPtr");
2944 TextLabel label = TextLabel::New();
2945 DALI_TEST_CHECK(label);
2947 application.GetScene().Add(label);
2949 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2950 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2951 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2952 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2953 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2954 label.SetProperty(TextLabel::Property::TEXT, "");
2956 // Avoid a crash when core load gl resources.
2957 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2959 unsigned int expectedCount = 0;
2960 unsigned int startIndex = 0;
2961 unsigned int endIndex = 0;
2963 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2964 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2966 // Render and notify
2967 application.SendNotification();
2968 application.Render();
2970 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2971 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2976 int UtcDaliToolkitTextlabelEllipsisPositionProperty(void)
2978 ToolkitTestApplication application;
2979 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty ");
2980 TextLabel textLabel = TextLabel::New();
2982 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Default is END");
2983 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
2985 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START");
2986 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
2987 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
2989 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE");
2990 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
2991 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
2993 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END");
2994 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
2995 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
2997 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using integer");
2998 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 1);
2999 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3001 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using integer");
3002 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 2);
3003 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3005 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using integer");
3006 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 0);
3007 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3009 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
3010 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "START");
3011 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3013 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
3014 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "MIDDLE");
3015 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3017 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
3018 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "END");
3019 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3021 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
3022 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "start");
3023 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3025 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
3026 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "middle");
3027 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3029 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
3030 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "end");
3031 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3036 int UtcDaliToolkitTextLabelStrikethroughGeneration(void)
3038 ToolkitTestApplication application;
3039 tet_infoline(" UtcDaliToolkitTextLabelStrikethroughGeneration");
3041 TextLabel textLabel = TextLabel::New();
3042 textLabel.SetProperty(TextLabel::Property::TEXT, "Test");
3043 textLabel.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
3044 textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3045 textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
3047 application.GetScene().Add(textLabel);
3048 application.SendNotification();
3049 application.Render();
3051 Property::Map strikethroughMapSet;
3052 Property::Map strikethroughMapGet;
3054 strikethroughMapSet.Insert("enable", true);
3055 strikethroughMapSet.Insert("color", Color::RED);
3056 strikethroughMapSet.Insert("height", 2.0f);
3058 // Check the strikethrough property
3059 textLabel.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
3060 strikethroughMapGet = textLabel.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
3061 textLabel.SetProperty(TextLabel::Property::TEXT, "Test1");
3062 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
3063 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
3065 // Render and notify
3066 application.SendNotification();
3067 application.Render();
3069 strikethroughMapSet.Clear();
3070 strikethroughMapGet.Clear();
3075 int UtcDaliToolkitTextLabelMarkupRelativeLineHeight(void)
3077 ToolkitTestApplication application;
3078 tet_infoline(" UtcDaliToolkitTextLabelMarkupRelativeLineHeight");
3080 TextLabel label = TextLabel::New();
3081 label.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3082 label.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3083 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3084 label.SetProperty(TextLabel::Property::TEXT, "line 1\nline 2\nline 3\nline 4\nline 5");
3085 label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3086 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
3087 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3089 TextLabel labelSingleLineParagraph = TextLabel::New();
3090 labelSingleLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3091 labelSingleLineParagraph.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3092 labelSingleLineParagraph.SetProperty(TextLabel::Property::MULTI_LINE, true);
3093 labelSingleLineParagraph.SetProperty(TextLabel::Property::TEXT, "<p>line 1</p><p rel-line-height=0.5>line 2</p>line 3<p rel-line-height=3>line 4</p>line 5");
3094 labelSingleLineParagraph.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3095 labelSingleLineParagraph.SetProperty(TextLabel::Property::ELLIPSIS, false);
3096 labelSingleLineParagraph.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3098 TextLabel labelMultiLineParagraph = TextLabel::New();
3099 labelMultiLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3100 labelMultiLineParagraph.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3101 labelMultiLineParagraph.SetProperty(TextLabel::Property::MULTI_LINE, true);
3102 labelMultiLineParagraph.SetProperty(TextLabel::Property::TEXT, "<p>line 1</p><p rel-line-height=0.5>line\n2</p>line 3<p rel-line-height=3>line\n4</p>line 5");
3103 labelMultiLineParagraph.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3104 labelMultiLineParagraph.SetProperty(TextLabel::Property::ELLIPSIS, false);
3105 labelMultiLineParagraph.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3107 application.GetScene().Add(label);
3108 application.GetScene().Add(labelSingleLineParagraph);
3109 application.GetScene().Add(labelMultiLineParagraph);
3110 application.SendNotification();
3111 application.Render();
3113 Vector3 naturalSize = label.GetNaturalSize();
3114 Vector3 relativeSingleNaturalSize = labelSingleLineParagraph.GetNaturalSize();
3115 Vector3 relativeMultiNaturalSize = labelMultiLineParagraph.GetNaturalSize();
3117 float lineSize = naturalSize.y / 5.0f; //total size/number of lines
3119 //no effect of relative line size for paragraph with single line
3120 DALI_TEST_EQUALS(naturalSize.y, relativeSingleNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3122 DALI_TEST_EQUALS(lineSize * 8.5f, relativeMultiNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3127 int UtcDaliToolkitTextLabelRelativeLineHeight(void)
3129 ToolkitTestApplication application;
3130 tet_infoline(" UtcDaliToolkitTextLabelRelativeLineHeight");
3132 TextLabel label = TextLabel::New();
3133 label.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3134 label.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3135 label.SetProperty(TextLabel::Property::TEXT, "Hello\nWorld");
3137 application.GetScene().Add(label);
3138 application.SendNotification();
3139 application.Render();
3141 Vector3 naturalSize = label.GetNaturalSize();
3143 label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 0.5f);
3145 application.SendNotification();
3146 application.Render();
3148 Vector3 relativeNaturalSize = label.GetNaturalSize();
3150 DALI_TEST_EQUALS(naturalSize.y, relativeNaturalSize.y, TEST_LOCATION);
3152 label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 2.0f);
3154 application.SendNotification();
3155 application.Render();
3157 relativeNaturalSize = label.GetNaturalSize();
3159 DALI_TEST_EQUALS(naturalSize.y * 2, relativeNaturalSize.y, TEST_LOCATION);
3163 int UtcDaliTextLabelCharacterSpacing(void)
3165 ToolkitTestApplication application;
3166 tet_infoline(" UtcDaliTextLabelCharacterSpacing ");
3168 TextLabel textLabel = TextLabel::New();
3170 textLabel.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
3172 application.GetScene().Add(textLabel);
3173 application.SendNotification();
3174 application.Render();
3176 textLabel.SetProperty(TextLabel::Property::TEXT, "Hi Experiment");
3177 textLabel.SetProperty(DevelTextLabel::Property::CHARACTER_SPACING, 10.f);
3178 DALI_TEST_EQUALS(textLabel.GetProperty<float>(DevelTextLabel::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3180 application.SendNotification();
3181 application.Render();
3186 int UtcDaliTextTextLabelSizeNegativeLineSpacing(void)
3188 ToolkitTestApplication application;
3189 tet_infoline("UtcDaliTextTextLabelSizeNegativeLineSpacing");
3191 TextLabel label = TextLabel::New();
3193 float lineSpacing = -20.f;
3195 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
3196 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
3197 label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
3198 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3199 label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
3201 application.GetScene().Add(label);
3202 application.SendNotification();
3203 application.Render();
3205 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, 0, 123);
3206 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, 0, 123);
3208 Vector2 lastLinePos = positionsList[positionsList.Size() - 1];
3209 Vector2 lastLineSize = sizeList[sizeList.Size() - 1];
3211 DALI_TEST_EQUALS(sizeList[0].y * (sizeList.Size() - 1), lastLinePos.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3212 DALI_TEST_EQUALS(sizeList[0].y - lineSpacing, lastLineSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3214 application.SendNotification();
3215 application.Render();
3220 int UtcDaliTextLabelNegativeLineSpacingWithEllipsis(void)
3222 ToolkitTestApplication application;
3223 tet_infoline("UtcDaliTextLabelNegativeLineSpacingWithEllipsis");
3225 TextLabel label = TextLabel::New();
3227 float lineSpacing = -20.f;
3229 label.SetProperty(Actor::Property::SIZE, Vector2(480.0f, 100.f));
3230 label.SetProperty(TextLabel::Property::POINT_SIZE, 11.0f);
3231 label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
3232 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3233 label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
3234 label.SetProperty(TextLabel::Property::ELLIPSIS, true);
3236 application.GetScene().Add(label);
3237 application.SendNotification();
3238 application.Render();
3240 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, 0, 123);
3242 int lineCount = sizeList.Size();
3243 DALI_TEST_EQUALS(4, lineCount, TEST_LOCATION);
3245 application.SendNotification();
3246 application.Render();
3251 int UtcDaliToolkitTextlabelParagraphTag(void)
3253 ToolkitTestApplication application;
3254 tet_infoline(" UtcDaliToolkitTextlabelParagraphTag");
3255 TextLabel labelNewlineSeparator = TextLabel::New();
3256 TextLabel labelParagraphTag = TextLabel::New();
3257 DALI_TEST_CHECK(labelNewlineSeparator);
3258 DALI_TEST_CHECK(labelParagraphTag);
3260 application.GetScene().Add(labelNewlineSeparator);
3261 application.GetScene().Add(labelParagraphTag);
3263 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
3264 labelNewlineSeparator.SetProperty(TextLabel::Property::MULTI_LINE, true);
3265 labelNewlineSeparator.SetProperty(TextLabel::Property::ELLIPSIS, false);
3266 labelNewlineSeparator.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3267 labelNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3268 labelNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3269 labelNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3270 labelNewlineSeparator.SetProperty(TextLabel::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
3272 labelParagraphTag.SetProperty(TextLabel::Property::MULTI_LINE, true);
3273 labelParagraphTag.SetProperty(TextLabel::Property::ELLIPSIS, false);
3274 labelParagraphTag.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3275 labelParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3276 labelParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3277 labelParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3278 labelParagraphTag.SetProperty(TextLabel::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
3280 application.SendNotification();
3281 application.Render();
3283 Vector3 textNaturalSizeNewlineSeparator = labelNewlineSeparator.GetNaturalSize();
3284 Vector3 textNaturalSizeParagraphTag = labelParagraphTag.GetNaturalSize();
3286 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
3288 application.SendNotification();
3289 application.Render();
3294 int utcDaliTextLabelGetTextBoundingRectangle(void)
3296 ToolkitTestApplication application;
3297 tet_infoline(" utcDaliTextLabelGeometryEllipsisMiddle");
3299 TextLabel label = TextLabel::New();
3300 DALI_TEST_CHECK(label);
3302 application.GetScene().Add(label);
3304 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
3305 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3306 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3307 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3308 label.SetProperty(TextLabel::Property::TEXT, "Hello this is the Text Bounding Rectangle TC");
3310 // Avoid a crash when core load gl resources.
3311 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3313 // Render and notify
3314 application.SendNotification();
3315 application.Render();
3317 unsigned int startIndex = 0;
3318 unsigned int endIndex = 15;
3320 Rect<> textBoundingRectangle = DevelTextLabel::GetTextBoundingRectangle(label, startIndex, endIndex);
3321 Rect<> expectedTextBoundingRectangle = {0, 0, 100, 25};
3323 TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);