2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali-toolkit-test-suite-utils.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
25 #include <dali-toolkit/devel-api/controls/text-controls/text-style-properties-devel.h>
26 #include <dali-toolkit/devel-api/text/bitmap-font.h>
27 #include <dali-toolkit/devel-api/text/rendering-backend.h>
28 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
29 #include <dali-toolkit/devel-api/text/text-utils-devel.h>
30 #include <dali/devel-api/adaptor-framework/image-loading.h>
31 #include <dali/devel-api/text-abstraction/bitmap-font.h>
32 #include <dali/devel-api/text-abstraction/font-client.h>
33 #include "test-text-geometry-utils.h"
36 using namespace Toolkit;
38 void dali_textlabel_startup(void)
40 test_return_value = TET_UNDEF;
43 void dali_textlabel_cleanup(void)
45 test_return_value = TET_PASS;
50 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT = "text";
52 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
55 const char* const PROPERTY_NAME_MULTI_LINE = "multiLine";
56 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
57 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
58 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
59 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
60 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL = "enableAutoScroll";
61 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
62 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
63 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP = "autoScrollGap";
65 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
66 const char* const PROPERTY_NAME_UNDERLINE = "underline";
67 const char* const PROPERTY_NAME_SHADOW = "shadow";
68 const char* const PROPERTY_NAME_EMBOSS = "emboss";
69 const char* const PROPERTY_NAME_OUTLINE = "outline";
70 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
71 const char* const PROPERTY_NAME_STRIKETHROUGH = "strikethrough";
73 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
74 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
75 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
76 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
77 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale";
79 const char* const PROPERTY_NAME_ELLIPSIS_POSITION = "ellipsisPosition";
80 const char* const PROPERTY_NAME_ANCHOR_COLOR = "anchorColor";
81 const char* const PROPERTY_NAME_ANCHOR_CLICKED_COLOR = "anchorClickedColor";
83 const char* const PROPERTY_NAME_REMOVE_FRONT_INSET = "removeFrontInset";
84 const char* const PROPERTY_NAME_REMOVE_BACK_INSET = "removeBackInset";
86 const std::string DEFAULT_FONT_DIR("/resources/fonts");
87 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
89 static bool gAnchorClickedCallBackCalled;
90 static bool gAnchorClickedCallBackNotCalled;
92 static bool gTextFitChangedCallBackCalled;
94 struct CallbackFunctor
96 CallbackFunctor(bool* callbackFlag)
97 : mCallbackFlag(callbackFlag)
103 *mCallbackFlag = true;
108 static void TestAnchorClickedCallback(TextLabel control, const char* href, unsigned int hrefLength)
110 tet_infoline(" TestAnchorClickedCallback");
112 gAnchorClickedCallBackNotCalled = false;
114 if(!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
116 gAnchorClickedCallBackCalled = true;
120 static void TestTextFitChangedCallback(TextLabel control)
122 tet_infoline(" TestTextFitChangedCallback");
123 gTextFitChangedCallBackCalled = true;
126 bool DaliTestCheckMaps(const Property::Map& mapGet, const Property::Map& mapSet, const std::vector<std::string>& indexConversionTable = std::vector<std::string>())
128 const Property::Map::SizeType size = mapGet.Count();
130 if(size == mapSet.Count())
132 for(unsigned int index = 0u; index < size; ++index)
134 const KeyValuePair& valueGet = mapGet.GetKeyValue(index);
136 // Find the keys of the 'get' map
137 Property::Index indexKey = valueGet.first.indexKey;
138 std::string stringKey = valueGet.first.stringKey;
140 if(!indexConversionTable.empty())
142 if(stringKey.empty())
144 stringKey = indexConversionTable[indexKey];
147 if((indexKey == Property::INVALID_INDEX) && !stringKey.empty())
149 Property::Index index = 0u;
150 for(auto key : indexConversionTable)
162 const Property::Value* const valueSet = mapSet.Find(indexKey, stringKey);
164 if(nullptr != valueSet)
166 if((valueSet->GetType() == Dali::Property::STRING) && (valueGet.second.Get<std::string>() != valueSet->Get<std::string>()))
168 tet_printf("Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str());
171 else if((valueSet->GetType() == Dali::Property::BOOLEAN) && (valueGet.second.Get<bool>() != valueSet->Get<bool>()))
173 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>());
176 else if((valueSet->GetType() == Dali::Property::INTEGER) && (valueGet.second.Get<int>() != valueSet->Get<int>()))
178 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>());
181 else if((valueSet->GetType() == Dali::Property::FLOAT) && (valueGet.second.Get<float>() != valueSet->Get<float>()))
183 tet_printf("Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>());
186 else if((valueSet->GetType() == Dali::Property::VECTOR2) && (valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>()))
188 Vector2 vector2Get = valueGet.second.Get<Vector2>();
189 Vector2 vector2Set = valueSet->Get<Vector2>();
190 tet_printf("Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y);
193 else if((valueSet->GetType() == Dali::Property::VECTOR4) && (valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>()))
195 Vector4 vector4Get = valueGet.second.Get<Vector4>();
196 Vector4 vector4Set = valueSet->Get<Vector4>();
197 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);
203 if(valueGet.first.type == Property::Key::INDEX)
205 tet_printf(" The key %d doesn't exist.", valueGet.first.indexKey);
209 tet_printf(" The key %s doesn't exist.", valueGet.first.stringKey.c_str());
221 int UtcDaliToolkitTextLabelConstructorP(void)
223 ToolkitTestApplication application;
224 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
226 DALI_TEST_CHECK(!textLabel);
230 int UtcDaliToolkitTextLabelNewP(void)
232 ToolkitTestApplication application;
233 tet_infoline(" UtcDaliToolkitTextLabelNewP");
234 TextLabel textLabel = TextLabel::New("Test Text");
235 DALI_TEST_CHECK(textLabel);
239 int UtcDaliToolkitTextLabelDownCastP(void)
241 ToolkitTestApplication application;
242 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
243 TextLabel textLabel1 = TextLabel::New();
244 BaseHandle object(textLabel1);
246 TextLabel textLabel2 = TextLabel::DownCast(object);
247 DALI_TEST_CHECK(textLabel2);
249 TextLabel textLabel3 = DownCast<TextLabel>(object);
250 DALI_TEST_CHECK(textLabel3);
254 int UtcDaliToolkitTextLabelDownCastN(void)
256 ToolkitTestApplication application;
257 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
258 BaseHandle uninitializedObject;
259 TextLabel textLabel1 = TextLabel::DownCast(uninitializedObject);
260 DALI_TEST_CHECK(!textLabel1);
262 TextLabel textLabel2 = DownCast<TextLabel>(uninitializedObject);
263 DALI_TEST_CHECK(!textLabel2);
267 int UtcDaliToolkitTextLabelCopyConstructorP(void)
269 ToolkitTestApplication application;
270 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
271 TextLabel textLabel = TextLabel::New();
272 textLabel.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
274 TextLabel copy(textLabel);
275 DALI_TEST_CHECK(copy);
276 DALI_TEST_CHECK(copy.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR) == textLabel.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR));
280 int UtcDaliTextLabelMoveConstructor(void)
282 ToolkitTestApplication application;
284 TextLabel textLabel = TextLabel::New();
285 textLabel.SetProperty(TextLabel::Property::TEXT, "Test");
286 DALI_TEST_CHECK(textLabel.GetProperty<std::string>(TextLabel::Property::TEXT) == "Test");
288 TextLabel moved = std::move(textLabel);
289 DALI_TEST_CHECK(moved);
290 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
291 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextLabel::Property::TEXT) == "Test");
292 DALI_TEST_CHECK(!textLabel);
297 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
299 ToolkitTestApplication application;
300 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
301 TextLabel textLabel = TextLabel::New();
302 textLabel.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
304 TextLabel copy = textLabel;
305 DALI_TEST_CHECK(copy);
306 DALI_TEST_CHECK(copy.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR) == textLabel.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR));
310 int UtcDaliTextLabelMoveAssignment(void)
312 ToolkitTestApplication application;
314 TextLabel textLabel = TextLabel::New();
315 textLabel.SetProperty(TextLabel::Property::TEXT, "Test");
316 DALI_TEST_CHECK(textLabel.GetProperty<std::string>(TextLabel::Property::TEXT) == "Test");
319 moved = std::move(textLabel);
320 DALI_TEST_CHECK(moved);
321 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
322 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextLabel::Property::TEXT) == "Test");
323 DALI_TEST_CHECK(!textLabel);
328 // Positive test case for a method
329 int UtcDaliToolkitTextLabelGetPropertyP(void)
331 ToolkitTestApplication application;
332 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
333 TextLabel label = TextLabel::New("Test Text");
334 DALI_TEST_CHECK(label);
336 // Check Property Indices are correct
337 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_RENDERING_BACKEND) == DevelTextLabel::Property::RENDERING_BACKEND);
338 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_TEXT) == TextLabel::Property::TEXT);
339 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_FONT_FAMILY) == TextLabel::Property::FONT_FAMILY);
340 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_FONT_STYLE) == TextLabel::Property::FONT_STYLE);
341 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_POINT_SIZE) == TextLabel::Property::POINT_SIZE);
342 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_MULTI_LINE) == TextLabel::Property::MULTI_LINE);
343 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_HORIZONTAL_ALIGNMENT) == TextLabel::Property::HORIZONTAL_ALIGNMENT);
344 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_VERTICAL_ALIGNMENT) == TextLabel::Property::VERTICAL_ALIGNMENT);
345 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_TEXT_COLOR) == TextLabel::Property::TEXT_COLOR);
346 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP);
347 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_AUTO_SCROLL) == TextLabel::Property::ENABLE_AUTO_SCROLL);
348 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED) == TextLabel::Property::AUTO_SCROLL_SPEED);
349 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT);
350 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP) == TextLabel::Property::AUTO_SCROLL_GAP);
351 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_LINE_SPACING) == TextLabel::Property::LINE_SPACING);
352 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_UNDERLINE) == TextLabel::Property::UNDERLINE);
353 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_SHADOW) == TextLabel::Property::SHADOW);
354 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_EMBOSS) == TextLabel::Property::EMBOSS);
355 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_OUTLINE) == TextLabel::Property::OUTLINE);
356 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_BACKGROUND) == DevelTextLabel::Property::BACKGROUND);
357 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_PIXEL_SIZE) == TextLabel::Property::PIXEL_SIZE);
358 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ELLIPSIS) == TextLabel::Property::ELLIPSIS);
359 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY);
360 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_FONT_SIZE_SCALE) == DevelTextLabel::Property::FONT_SIZE_SCALE);
361 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE);
362 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ELLIPSIS_POSITION) == DevelTextLabel::Property::ELLIPSIS_POSITION);
363 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextLabel::Property::STRIKETHROUGH);
364 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ANCHOR_COLOR) == DevelTextLabel::Property::ANCHOR_COLOR);
365 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ANCHOR_CLICKED_COLOR) == DevelTextLabel::Property::ANCHOR_CLICKED_COLOR);
366 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_REMOVE_FRONT_INSET) == DevelTextLabel::Property::REMOVE_FRONT_INSET);
367 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_REMOVE_BACK_INSET) == DevelTextLabel::Property::REMOVE_BACK_INSET);
372 int UtcDaliToolkitTextLabelSetPropertyP(void)
374 ToolkitTestApplication application;
375 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
376 TextLabel label = TextLabel::New();
377 DALI_TEST_CHECK(label);
379 application.GetScene().Add(label);
381 // Note - we can't check the defaults since the stylesheets are platform-specific
382 label.SetProperty(DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
383 DALI_TEST_EQUALS((DevelText::RenderingType)label.GetProperty<int>(DevelTextLabel::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
385 // Check that text can be correctly reset
386 label.SetProperty(TextLabel::Property::TEXT, "Setting Text");
387 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
389 // Check font properties.
390 label.SetProperty(TextLabel::Property::FONT_FAMILY, "Setting font family");
391 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
393 Property::Map fontStyleMapSet;
394 Property::Map fontStyleMapGet;
396 fontStyleMapSet.Insert("weight", "bold");
397 fontStyleMapSet.Insert("width", "condensed");
398 fontStyleMapSet.Insert("slant", "italic");
399 label.SetProperty(TextLabel::Property::FONT_STYLE, fontStyleMapSet);
401 fontStyleMapGet = label.GetProperty<Property::Map>(TextLabel::Property::FONT_STYLE);
402 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
403 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
405 // Check the old font style format.
406 fontStyleMapSet.Clear();
407 fontStyleMapSet.Insert("weight", "thin");
408 fontStyleMapSet.Insert("width", "expanded");
409 fontStyleMapSet.Insert("slant", "oblique");
410 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
412 label.SetProperty(TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}");
413 std::string getFontStyle = label.GetProperty<std::string>(TextLabel::Property::FONT_STYLE);
414 DALI_TEST_EQUALS(getFontStyle, strFontStyle, TEST_LOCATION);
416 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
417 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
419 label.SetProperty(DevelTextLabel::Property::FONT_SIZE_SCALE, 2.5f);
420 DALI_TEST_EQUALS(label.GetProperty<float>(DevelTextLabel::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
421 label.SetProperty(DevelTextLabel::Property::FONT_SIZE_SCALE, 1.0f);
423 label.SetProperty(DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE, false);
424 DALI_TEST_EQUALS(label.GetProperty<bool>(DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
425 label.SetProperty(DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE, true);
428 fontStyleMapSet.Clear();
429 fontStyleMapSet.Insert("weight", "normal");
430 fontStyleMapSet.Insert("slant", "oblique");
432 label.SetProperty(TextLabel::Property::FONT_STYLE, fontStyleMapSet);
433 fontStyleMapGet = label.GetProperty<Property::Map>(TextLabel::Property::FONT_STYLE);
434 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
435 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
437 fontStyleMapSet.Clear();
438 fontStyleMapSet.Insert("slant", "roman");
440 label.SetProperty(TextLabel::Property::FONT_STYLE, fontStyleMapSet);
441 fontStyleMapGet = label.GetProperty<Property::Map>(TextLabel::Property::FONT_STYLE);
442 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
444 // Replace 'roman' for 'normal'.
445 Property::Value* slantValue = fontStyleMapGet.Find("slant");
446 if(NULL != slantValue)
448 if("normal" == slantValue->Get<std::string>())
450 fontStyleMapGet["slant"] = "roman";
453 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
455 fontStyleMapSet.Clear();
457 label.SetProperty(TextLabel::Property::FONT_STYLE, fontStyleMapSet);
458 fontStyleMapGet = label.GetProperty<Property::Map>(TextLabel::Property::FONT_STYLE);
459 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
460 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
463 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
464 DALI_TEST_EQUALS(label.GetProperty<bool>(TextLabel::Property::MULTI_LINE), true, TEST_LOCATION);
466 // Check that the Alignment properties can be correctly set
467 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
468 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::HORIZONTAL_ALIGNMENT), "CENTER", TEST_LOCATION);
469 label.SetProperty(TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
470 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
472 // Check that text color can be properly set
473 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLUE);
474 DALI_TEST_EQUALS(label.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR), Color::BLUE, TEST_LOCATION);
476 // Check that anchor color can be properly set
477 label.SetProperty(DevelTextLabel::Property::ANCHOR_COLOR, Color::BLUE);
478 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_COLOR), Color::BLUE, TEST_LOCATION);
480 label.SetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR, Color::RED);
481 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR), Color::RED, TEST_LOCATION);
483 Property::Map strikethroughMapSet;
484 Property::Map strikethroughMapGet;
486 strikethroughMapSet.Insert("enable", false);
487 strikethroughMapSet.Insert("color", Color::BLUE);
488 strikethroughMapSet.Insert("height", 2.0f);
490 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
492 strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
493 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
494 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
496 Property::Map underlineMapSet;
497 Property::Map underlineMapGet;
499 underlineMapSet.Insert("enable", false);
500 underlineMapSet.Insert("color", Color::BLUE);
501 underlineMapSet.Insert("height", 0);
502 underlineMapSet.Insert("type", Text::Underline::SOLID);
503 underlineMapSet.Insert("dashWidth", 2);
504 underlineMapSet.Insert("dashGap", 1);
506 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
508 application.SendNotification();
509 application.Render();
511 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
512 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
513 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
516 underlineMapSet.Clear();
517 underlineMapGet.Clear();
519 underlineMapSet.Insert("enable", false);
520 underlineMapSet.Insert("color", Color::BLUE);
521 underlineMapSet.Insert("height", 0);
522 underlineMapSet.Insert("type", Text::Underline::DASHED);
523 underlineMapSet.Insert("dashWidth", 2);
524 underlineMapSet.Insert("dashGap", 1);
526 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
528 application.SendNotification();
529 application.Render();
531 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
532 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
533 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
536 underlineMapSet.Clear();
537 underlineMapGet.Clear();
539 underlineMapSet.Insert("enable", false);
540 underlineMapSet.Insert("color", Color::BLUE);
541 underlineMapSet.Insert("height", 0);
542 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
543 underlineMapSet.Insert("dashWidth", 2);
544 underlineMapSet.Insert("dashGap", 1);
546 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
548 application.SendNotification();
549 application.Render();
551 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
552 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
553 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
555 TextLabel label2 = TextLabel::New("New text");
556 DALI_TEST_CHECK(label2);
557 DALI_TEST_EQUALS(label2.GetProperty<std::string>(TextLabel::Property::TEXT), std::string("New text"), TEST_LOCATION);
559 // Check the enable markup property.
560 DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ENABLE_MARKUP));
561 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
562 DALI_TEST_CHECK(label.GetProperty<bool>(TextLabel::Property::ENABLE_MARKUP));
564 // Check the text property when markup is enabled
565 label.SetProperty(TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>");
566 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::TEXT), std::string("MarkupText"), TEST_LOCATION);
568 // Check for incomplete marks.
569 label.SetProperty(TextLabel::Property::TEXT, "<color='white'><i>Markup</i><b>Text</b></color>");
570 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::TEXT), std::string("MarkupText"), TEST_LOCATION);
573 application.SendNotification();
574 application.Render();
578 tet_result(TET_FAIL);
581 // Check autoscroll properties
582 const int SCROLL_SPEED = 80;
583 const int SCROLL_LOOPS = 4;
584 const float SCROLL_GAP = 50.0f;
585 const float SCROLL_LOOP_DELAY = 0.3f;
586 const std::string STOP_IMMEDIATE = std::string("IMMEDIATE");
587 const std::string STOP_FINISH_LOOP = std::string("FINISH_LOOP");
589 label.SetProperty(TextLabel::Property::MULTI_LINE, false); // Autoscroll only supported in single line
590 DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ENABLE_AUTO_SCROLL));
591 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
592 DALI_TEST_CHECK(label.GetProperty<bool>(TextLabel::Property::ENABLE_AUTO_SCROLL));
593 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED);
594 DALI_TEST_EQUALS(SCROLL_SPEED, label.GetProperty<int>(TextLabel::Property::AUTO_SCROLL_SPEED), TEST_LOCATION);
595 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS);
596 DALI_TEST_EQUALS(SCROLL_LOOPS, label.GetProperty<int>(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT), TEST_LOCATION);
597 label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP);
598 DALI_TEST_EQUALS(SCROLL_GAP, label.GetProperty<float>(TextLabel::Property::AUTO_SCROLL_GAP), TEST_LOCATION);
599 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY);
600 DALI_TEST_EQUALS(SCROLL_LOOP_DELAY, label.GetProperty<float>(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY), TEST_LOCATION);
602 //Check autoscroll stop type property
603 label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
604 DALI_TEST_EQUALS(STOP_IMMEDIATE, label.GetProperty<std::string>(TextLabel::Property::AUTO_SCROLL_STOP_MODE), TEST_LOCATION);
606 label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
607 DALI_TEST_EQUALS(STOP_FINISH_LOOP, label.GetProperty<std::string>(TextLabel::Property::AUTO_SCROLL_STOP_MODE), TEST_LOCATION);
609 // test natural size with multi-line and line spacing
611 TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
612 Vector3 oneLineNaturalSize = label3.GetNaturalSize();
613 label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
614 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
615 Vector3 multiLineNaturalSize = label3.GetNaturalSize();
617 // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
618 // The height of the text when multi-line is enabled will be larger
619 DALI_TEST_CHECK(oneLineNaturalSize.width > multiLineNaturalSize.width);
620 DALI_TEST_CHECK(oneLineNaturalSize.height < multiLineNaturalSize.height);
622 // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
623 // Everything else will remain the same
624 int lineSpacing = 20;
625 label3.SetProperty(TextLabel::Property::LINE_SPACING, lineSpacing);
626 Vector3 expectedAfterLineSpacingApplied(multiLineNaturalSize);
627 expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
628 DALI_TEST_EQUALS(expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION);
631 // single line, line spacing must not affect natural size of the text, only add the spacing to the height
633 TextLabel label3 = TextLabel::New("Some text here end there end here");
634 label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
635 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
636 Vector3 textNaturalSize = label3.GetNaturalSize();
637 int lineSpacing = 20;
638 label3.SetProperty(TextLabel::Property::LINE_SPACING, lineSpacing);
639 Vector3 expectedNaturalSizeWithLineSpacing(textNaturalSize);
640 expectedNaturalSizeWithLineSpacing.height += lineSpacing;
641 DALI_TEST_EQUALS(expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION);
643 // Check the line spacing property
644 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::LINE_SPACING), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
645 label.SetProperty(TextLabel::Property::LINE_SPACING, 10.f);
646 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::LINE_SPACING), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
648 // Check the strikethrough property
649 strikethroughMapSet.Clear();
650 strikethroughMapSet.Insert("enable", true);
651 strikethroughMapSet.Insert("color", Color::RED);
652 strikethroughMapSet.Insert("height", 2.0f);
654 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
656 application.SendNotification();
657 application.Render();
659 strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
660 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
661 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
663 // Check the transparent strikethrough property for coverage.
664 strikethroughMapSet.Clear();
665 strikethroughMapSet.Insert("enable", true);
666 strikethroughMapSet.Insert("color", Color::TRANSPARENT);
667 strikethroughMapSet.Insert("height", 2.0f);
669 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
671 application.SendNotification();
672 application.Render();
674 strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
675 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
676 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
678 strikethroughMapSet.Clear();
679 strikethroughMapSet.Insert(Toolkit::DevelText::Strikethrough::Property::ENABLE, true);
680 strikethroughMapSet.Insert(Toolkit::DevelText::Strikethrough::Property::COLOR, Color::RED);
681 strikethroughMapSet.Insert(Toolkit::DevelText::Strikethrough::Property::HEIGHT, 2.0f);
683 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
685 application.SendNotification();
686 application.Render();
688 strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
689 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
690 std::vector<std::string> strikethroughIndicesConversionTable = {"enable", "color", "height"};
691 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet, strikethroughIndicesConversionTable), true, TEST_LOCATION);
693 strikethroughMapSet.Clear();
695 Property::Map strikethroughDisabledMapGet;
696 strikethroughDisabledMapGet.Insert("enable", false);
697 strikethroughDisabledMapGet.Insert("color", Color::RED);
698 strikethroughDisabledMapGet.Insert("height", 2.0f);
700 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
702 application.SendNotification();
703 application.Render();
705 strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
706 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughDisabledMapGet.Count(), TEST_LOCATION);
707 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughDisabledMapGet), true, TEST_LOCATION);
709 // Check the underline property
710 underlineMapSet.Clear();
711 underlineMapSet.Insert("enable", true);
712 underlineMapSet.Insert("color", Color::RED);
713 underlineMapSet.Insert("height", 1);
714 underlineMapSet.Insert("type", Text::Underline::SOLID);
715 underlineMapSet.Insert("dashWidth", 2);
716 underlineMapSet.Insert("dashGap", 1);
718 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
720 application.SendNotification();
721 application.Render();
723 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
724 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
725 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
727 underlineMapSet.Clear();
728 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::ENABLE, true);
729 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN);
730 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::HEIGHT, 2);
731 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::TYPE, Text::Underline::DASHED);
732 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_WIDTH, 2);
733 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_GAP, 1);
735 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
737 application.SendNotification();
738 application.Render();
740 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
741 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
742 std::vector<std::string> underlineIndicesConversionTable = {"enable", "color", "height", "type", "dashWidth", "dashGap"};
743 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet, underlineIndicesConversionTable), true, TEST_LOCATION);
745 underlineMapSet.Clear();
747 Property::Map underlineDisabledMapGet;
748 underlineDisabledMapGet.Insert("enable", false);
749 underlineDisabledMapGet.Insert("color", Color::GREEN);
750 underlineDisabledMapGet.Insert("height", 2);
751 underlineDisabledMapGet.Insert("type", Text::Underline::SOLID);
752 underlineDisabledMapGet.Insert("dashWidth", 2);
753 underlineDisabledMapGet.Insert("dashGap", 1);
755 label.SetProperty(TextLabel::Property::UNDERLINE, underlineDisabledMapGet);
757 application.SendNotification();
758 application.Render();
760 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
761 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION);
762 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineDisabledMapGet), true, TEST_LOCATION);
764 // Check the dashed underline property
765 underlineMapSet.Clear();
766 underlineMapSet.Insert("enable", true);
767 underlineMapSet.Insert("color", Color::RED);
768 underlineMapSet.Insert("height", 1);
769 underlineMapSet.Insert("type", Text::Underline::DASHED);
770 underlineMapSet.Insert("dashWidth", 2);
771 underlineMapSet.Insert("dashGap", 1);
773 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
775 application.SendNotification();
776 application.Render();
778 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
779 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
780 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
782 underlineMapSet.Clear();
783 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::ENABLE, true);
784 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN);
785 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::HEIGHT, 2);
786 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::TYPE, Text::Underline::DASHED);
787 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_WIDTH, 2);
788 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_GAP, 1);
790 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
792 application.SendNotification();
793 application.Render();
795 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
796 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
797 underlineIndicesConversionTable = {"enable", "color", "height", "type", "dashWidth", "dashGap"};
798 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet, underlineIndicesConversionTable), true, TEST_LOCATION);
800 underlineMapSet.Clear();
802 underlineDisabledMapGet.Clear();
803 underlineDisabledMapGet.Insert("enable", false);
804 underlineDisabledMapGet.Insert("color", Color::GREEN);
805 underlineDisabledMapGet.Insert("height", 2);
806 underlineDisabledMapGet.Insert("type", Text::Underline::DASHED);
807 underlineDisabledMapGet.Insert("dashWidth", 2);
808 underlineDisabledMapGet.Insert("dashGap", 1);
810 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
812 application.SendNotification();
813 application.Render();
815 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
816 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION);
817 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineDisabledMapGet), true, TEST_LOCATION);
819 // Check the double underline property
820 underlineMapSet.Clear();
821 underlineMapSet.Insert("enable", true);
822 underlineMapSet.Insert("color", Color::RED);
823 underlineMapSet.Insert("height", 1);
824 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
825 underlineMapSet.Insert("dashWidth", 2);
826 underlineMapSet.Insert("dashGap", 1);
828 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
830 application.SendNotification();
831 application.Render();
833 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
834 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
835 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
837 // Check the transparent double underline property for coverage.
838 underlineMapSet.Clear();
839 underlineMapSet.Insert("enable", true);
840 underlineMapSet.Insert("color", Color::TRANSPARENT);
841 underlineMapSet.Insert("height", 1);
842 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
843 underlineMapSet.Insert("dashWidth", 2);
844 underlineMapSet.Insert("dashGap", 1);
846 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
848 application.SendNotification();
849 application.Render();
851 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
852 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
853 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
855 underlineMapSet.Clear();
856 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::ENABLE, true);
857 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN);
858 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::HEIGHT, 2);
859 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::TYPE, Text::Underline::DOUBLE);
860 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_WIDTH, 2);
861 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_GAP, 1);
863 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
865 application.SendNotification();
866 application.Render();
868 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
869 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
870 underlineIndicesConversionTable = {"enable", "color", "height", "type", "dashWidth", "dashGap"};
871 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet, underlineIndicesConversionTable), true, TEST_LOCATION);
873 underlineMapSet.Clear();
875 underlineDisabledMapGet.Clear();
876 underlineDisabledMapGet.Insert("enable", false);
877 underlineDisabledMapGet.Insert("color", Color::GREEN);
878 underlineDisabledMapGet.Insert("height", 2);
879 underlineDisabledMapGet.Insert("type", Text::Underline::DOUBLE);
880 underlineDisabledMapGet.Insert("dashWidth", 2);
881 underlineDisabledMapGet.Insert("dashGap", 1);
883 label.SetProperty(TextLabel::Property::UNDERLINE, underlineDisabledMapGet);
885 application.SendNotification();
886 application.Render();
888 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
889 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION);
890 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineDisabledMapGet), true, TEST_LOCATION);
892 // Check the shadow property
894 Property::Map shadowMapSet;
895 Property::Map shadowMapGet;
897 shadowMapSet.Insert("color", Color::GREEN);
898 shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
899 shadowMapSet.Insert("blurRadius", 5.0f);
901 label.SetProperty(TextLabel::Property::SHADOW, shadowMapSet);
903 shadowMapGet = label.GetProperty<Property::Map>(TextLabel::Property::SHADOW);
904 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
905 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
907 shadowMapSet.Clear();
909 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE);
910 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0");
911 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f);
913 label.SetProperty(TextLabel::Property::SHADOW, shadowMapSet);
915 // Replace the offset (string) by a vector2
916 shadowMapSet.Clear();
917 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE);
918 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::OFFSET, Vector2(3.0, 3.0));
919 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f);
921 shadowMapGet = label.GetProperty<Property::Map>(TextLabel::Property::SHADOW);
922 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
923 std::vector<std::string> shadowIndicesConversionTable = {"color", "offset", "blurRadius"};
924 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet, shadowIndicesConversionTable), true, TEST_LOCATION);
926 shadowMapSet.Clear();
927 Property::Map shadowDisabledMapGet;
928 shadowDisabledMapGet.Insert("color", Color::BLUE);
929 shadowDisabledMapGet.Insert("offset", Vector2(0.0f, 0.0f));
930 shadowDisabledMapGet.Insert("blurRadius", 3.0f);
932 label.SetProperty(TextLabel::Property::SHADOW, shadowMapSet);
934 shadowMapGet = label.GetProperty<Property::Map>(TextLabel::Property::SHADOW);
935 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION);
936 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowDisabledMapGet), true, TEST_LOCATION);
938 // Check the emboss property
939 label.SetProperty(TextLabel::Property::EMBOSS, "Emboss properties");
940 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
942 // Check the outline property
944 // Test string type first
945 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
946 label.SetProperty(TextLabel::Property::OUTLINE, "Outline properties");
947 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
949 // Then test the property map type
950 Property::Map outlineMapSet;
951 Property::Map outlineMapGet;
953 outlineMapSet["color"] = Color::RED;
954 outlineMapSet["width"] = 2.0f;
955 outlineMapSet["offset"] = Vector2(2.0f, 2.0f);
956 outlineMapSet["blurRadius"] = 3.0f;
957 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
959 outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
960 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
961 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
963 outlineMapSet.Clear();
964 outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
965 outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
966 outlineMapSet[Toolkit::DevelText::Outline::Property::OFFSET] = Vector2(3.0f, 3.0f);
967 outlineMapSet[Toolkit::DevelText::Outline::Property::BLUR_RADIUS] = 4.0f;
969 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
971 outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
972 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
973 std::vector<std::string> outlineIndicesConversionTable = {"color", "width", "offset", "blurRadius"};
974 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet, outlineIndicesConversionTable), true, TEST_LOCATION);
976 // Check the background property
977 Property::Map backgroundMapSet;
978 Property::Map backgroundMapGet;
980 backgroundMapSet["enable"] = true;
981 backgroundMapSet["color"] = Color::RED;
982 label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
984 backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
985 DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
986 DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet), true, TEST_LOCATION);
988 // Check the transparent background property for coverage
989 backgroundMapSet.Clear();
990 backgroundMapSet["enable"] = true;
991 backgroundMapSet["color"] = Color::TRANSPARENT;
992 label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
994 application.SendNotification();
995 application.Render();
997 backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
998 DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
999 DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet), true, TEST_LOCATION);
1001 backgroundMapSet.Clear();
1002 backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
1003 backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
1004 label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
1006 backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
1007 DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
1008 std::vector<std::string> backgroundIndicesConversionTable = {"enable", "color"};
1009 DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable), true, TEST_LOCATION);
1011 // Check the pixel size of font
1012 label.SetProperty(TextLabel::Property::PIXEL_SIZE, 20.f);
1013 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1015 // Check the ellipsis property
1016 DALI_TEST_CHECK(label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
1017 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
1018 DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
1020 // Check the layout direction property
1021 label.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1022 DALI_TEST_EQUALS(label.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1024 // Check the line size property
1025 DALI_TEST_EQUALS(label.GetProperty<float>(DevelTextLabel::Property::MIN_LINE_SIZE), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1026 label.SetProperty(DevelTextLabel::Property::MIN_LINE_SIZE, 50.f);
1027 DALI_TEST_EQUALS(label.GetProperty<float>(DevelTextLabel::Property::MIN_LINE_SIZE), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1029 application.SendNotification();
1030 application.Render();
1032 // Check Remove Front/Back Inset Property
1033 DALI_TEST_CHECK(label.GetProperty<bool>(DevelTextLabel::Property::REMOVE_FRONT_INSET));
1034 label.SetProperty(DevelTextLabel::Property::REMOVE_FRONT_INSET, false);
1035 DALI_TEST_CHECK(!label.GetProperty<bool>(DevelTextLabel::Property::REMOVE_FRONT_INSET));
1037 DALI_TEST_CHECK(label.GetProperty<bool>(DevelTextLabel::Property::REMOVE_BACK_INSET));
1038 label.SetProperty(DevelTextLabel::Property::REMOVE_BACK_INSET, false);
1039 DALI_TEST_CHECK(!label.GetProperty<bool>(DevelTextLabel::Property::REMOVE_BACK_INSET));
1041 application.SendNotification();
1042 application.Render();
1047 int UtcDaliToolkitTextlabelAtlasRenderP(void)
1049 ToolkitTestApplication application;
1050 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
1051 TextLabel label = TextLabel::New("Test Text");
1052 DALI_TEST_CHECK(label);
1054 // Avoid a crash when core load gl resources.
1055 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1057 application.GetScene().Add(label);
1059 // Turn on all the effects
1060 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1061 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1063 Property::Map underlineMap;
1064 underlineMap.Insert("enable", true);
1065 underlineMap.Insert("color", Color::RED);
1066 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMap);
1068 Property::Map shadowMap;
1069 shadowMap.Insert("color", Color::BLUE);
1070 shadowMap.Insert("offset", Vector2(1.0f, 1.0f));
1071 label.SetProperty(TextLabel::Property::SHADOW, shadowMap);
1073 Property::Map strikethroughMap;
1074 strikethroughMap.Insert("enable", true);
1075 strikethroughMap.Insert("color", Color::GREEN);
1076 strikethroughMap.Insert("height", 2.0f);
1077 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMap);
1081 // Render some text with the shared atlas backend
1082 label.SetProperty(DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1083 application.SendNotification();
1084 application.Render();
1088 tet_result(TET_FAIL);
1093 // Render some text with the shared atlas backend
1094 label.SetProperty(DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED);
1095 application.SendNotification();
1096 application.Render();
1100 tet_result(TET_FAIL);
1105 int UtcDaliToolkitTextLabelLanguagesP(void)
1107 ToolkitTestApplication application;
1108 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
1109 TextLabel label = TextLabel::New();
1110 DALI_TEST_CHECK(label);
1112 application.GetScene().Add(label);
1114 const std::string scripts(
1115 " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
1116 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
1117 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
1118 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
1119 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
1120 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84."); // these characters on the last line are emojis.
1122 label.SetProperty(TextLabel::Property::TEXT, scripts);
1123 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::TEXT), scripts, TEST_LOCATION);
1125 application.SendNotification();
1126 application.Render();
1131 int UtcDaliToolkitTextLabelEmojisP(void)
1133 ToolkitTestApplication application;
1134 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
1135 TextLabel label = TextLabel::New();
1136 DALI_TEST_CHECK(label);
1138 application.GetScene().Add(label);
1140 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1142 char* pathNamePtr = get_current_dir_name();
1143 const std::string pathName(pathNamePtr);
1146 TextAbstraction::FontDescription fontDescription;
1147 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
1148 fontDescription.family = "BreezeColorEmoji";
1149 fontDescription.width = TextAbstraction::FontWidth::NONE;
1150 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
1151 fontDescription.slant = TextAbstraction::FontSlant::NONE;
1153 fontClient.GetFontId(fontDescription, EMOJI_FONT_SIZE);
1155 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>";
1156 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1157 label.SetProperty(TextLabel::Property::TEXT, emojis);
1159 Property::Map shadowMap;
1160 shadowMap.Insert("color", "green");
1161 shadowMap.Insert("offset", "2 2");
1162 label.SetProperty(TextLabel::Property::SHADOW, shadowMap);
1164 application.SendNotification();
1165 application.Render();
1167 // EMOJI + ZWJ + EMOJI case for coverage.
1168 const std::string emojiWithZWJ = "👩‍🔬";
1169 label.SetProperty(TextLabel::Property::TEXT, emojiWithZWJ);
1171 application.SendNotification();
1172 application.Render();
1174 // EMOJI Sequences case for coverage.
1175 std::string emojiSequences =
1176 "Glyphs not included in the font \n" //case for coverage when glyph is not included in the font
1177 "Text VS15 ☪︎\n" //text presentation sequence and selector
1178 "Color VS16 ☪️\n" //emoji presentation sequence and selector
1179 "Default ☪ \n" //default presentation
1180 "FamilyManWomanGirlBoy 👨‍👩‍👧‍👦\n" // emoji multi zwj sequence
1181 "WomanScientist 👩‍🔬\n" // emoji zwj sequence
1182 "WomanScientistLightSkinTone👩🏻‍🔬 \n" // emoji modifier sequence: skin tone & JWZ
1183 "LeftRightArrowText↔︎\n" // text presentation sequence and selector
1184 "LeftRightArrowEmoji↔️\n" // emoji presentation sequence and selector
1185 "SouthKoreaFlag🇰🇷\n" // emoji flag sequence
1186 "JordanFlag🇯🇴\n" // emoji flag sequence
1187 "EnglandFlag🏴󠁧󠁢󠁥󠁮󠁧󠁿\n" // emoji tag sequence like England flag
1188 "Runner 🏃‍➡️ \n"
1189 "VictoryHandMediumLightSkinTone:✌️🏼\n" // emoji modifier sequence: skin tone
1190 "RainbowFlag:🏳️‍🌈 \n" // emoji zwj sequence: Rainbow Flag
1191 "keycap# #️⃣ \n" // fully-qualified emoji keycap sequence
1192 "keycap#_text #⃣ \n" // unqualified emoji keycap sequence
1193 "keycap3 3️⃣ \n" // fully-qualified emoji keycap sequence
1194 "keycap3_text 3⃣ \n" // unqualified emoji keycap sequence
1195 "two adjacent glyphs ☪️️️☪️\n" // This line should be rendered as two adjacent glyphs
1196 "Digit 8️ 8︎ 8\n" // should be rendered according to selector
1197 "Surfing Medium Skin Female: 🏄🏼‍♀️\n" // Person Surfing + Medium Skin Tone +? Zero Width Joiner + Female Sign
1198 "SYMBOLS_NSLCL variation selector: 🅰️🅱️🅲︎🅳︎🅴︎\n" // 1F170 ~ 1F174 with variation selector, text vs emoji
1199 "SYMBOLS_NSLCL with VS15: 🅰︎🅱︎🅲︎🅳︎🅴︎\n" // 1F170 ~ 1F174 with VS15
1200 "SYMBOLS_NSLCL with VS16: 🅰️🅱️🅲️🅳️🅴️\n" // 1F170 ~ 1F174 with VS16
1204 label.SetProperty(TextLabel::Property::TEXT, emojiSequences);
1205 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1206 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1207 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
1209 application.SendNotification();
1210 application.Render();
1214 int UtcDaliToolkitTextlabelScrollingP(void)
1216 ToolkitTestApplication application;
1217 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
1218 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
1219 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
1221 DALI_TEST_CHECK(labelImmediate);
1222 DALI_TEST_CHECK(labelFinished);
1223 // Avoid a crash when core load gl resources.
1224 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1225 application.GetScene().Add(labelImmediate);
1226 // Turn on all the effects
1227 labelImmediate.SetProperty(TextLabel::Property::MULTI_LINE, false);
1228 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1229 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1230 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1231 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1233 application.GetScene().Add(labelFinished);
1234 // Turn on all the effects
1235 labelFinished.SetProperty(TextLabel::Property::MULTI_LINE, false);
1236 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1237 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1238 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1239 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1243 // Render some text with the shared atlas backend
1244 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1245 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1247 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1248 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1250 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1251 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1252 application.SendNotification();
1253 application.Render();
1255 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1256 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1257 application.SendNotification();
1258 application.Render();
1262 tet_result(TET_FAIL);
1268 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
1270 ToolkitTestApplication application;
1271 TextLabel labelShort = TextLabel::New("Some text to scroll");
1272 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!");
1274 DALI_TEST_CHECK(labelShort);
1275 DALI_TEST_CHECK(labelLong);
1276 // Avoid a crash when core load gl resources.
1277 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1278 application.GetScene().Add(labelShort);
1279 // Turn on all the effects
1280 labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1281 labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1282 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1283 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1284 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1285 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1287 application.GetScene().Add(labelLong);
1288 // Turn on all the effects
1289 labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1290 labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1291 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1292 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1293 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1294 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1298 // Render some text with the shared atlas backend
1299 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1300 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1301 application.SendNotification();
1302 application.Render();
1304 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1305 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1306 application.SendNotification();
1307 application.Render();
1311 tet_result(TET_FAIL);
1317 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
1319 ToolkitTestApplication application;
1320 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1321 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1323 DALI_TEST_CHECK(labelShort);
1324 DALI_TEST_CHECK(labelLong);
1325 // Avoid a crash when core load gl resources.
1326 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1327 application.GetScene().Add(labelShort);
1328 // Turn on all the effects
1329 labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1330 labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1331 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1332 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1333 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1334 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1336 application.GetScene().Add(labelLong);
1337 // Turn on all the effects
1338 labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1339 labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1340 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1341 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1342 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1343 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1347 // Render some text with the shared atlas backend
1348 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1349 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1350 application.SendNotification();
1351 application.Render();
1353 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1354 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1355 application.SendNotification();
1356 application.Render();
1360 tet_result(TET_FAIL);
1366 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
1368 ToolkitTestApplication application;
1369 TextLabel labelShort = TextLabel::New("Some text to scroll");
1370 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!");
1372 DALI_TEST_CHECK(labelShort);
1373 DALI_TEST_CHECK(labelLong);
1374 // Avoid a crash when core load gl resources.
1375 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1376 application.GetScene().Add(labelShort);
1377 // Turn on all the effects
1378 labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1379 labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1380 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1381 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1382 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1383 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1385 application.GetScene().Add(labelLong);
1386 // Turn on all the effects
1387 labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1388 labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1389 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1390 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1391 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1392 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1396 // Render some text with the shared atlas backend
1397 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1398 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1399 application.SendNotification();
1400 application.Render();
1402 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1403 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1404 application.SendNotification();
1405 application.Render();
1409 tet_result(TET_FAIL);
1415 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
1417 ToolkitTestApplication application;
1418 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1419 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1421 DALI_TEST_CHECK(labelShort);
1422 DALI_TEST_CHECK(labelLong);
1423 // Avoid a crash when core load gl resources.
1424 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1425 application.GetScene().Add(labelShort);
1426 // Turn on all the effects
1427 labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1428 labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1429 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1430 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1431 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1432 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1434 application.GetScene().Add(labelLong);
1435 // Turn on all the effects
1436 labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1437 labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1438 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1439 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1440 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1441 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1445 // Render some text with the shared atlas backend
1446 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1447 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1448 application.SendNotification();
1449 application.Render();
1451 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1452 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1453 application.SendNotification();
1454 application.Render();
1458 tet_result(TET_FAIL);
1464 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1466 ToolkitTestApplication application;
1467 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1468 TextLabel label = TextLabel::New("Some text to scroll");
1469 DALI_TEST_CHECK(label);
1470 // Avoid a crash when core load gl resources.
1471 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1472 application.GetScene().Add(label);
1473 label.SetProperty(Actor::Property::SIZE, Vector2(360.0f, 20.f));
1474 // Turn on all the effects
1475 label.SetProperty(TextLabel::Property::MULTI_LINE, false);
1476 label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1477 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1478 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1481 application.SendNotification();
1482 application.Render();
1484 unsigned int actorCount1 = label.GetChildCount();
1485 tet_printf("Initial actor count is(%d)\n", actorCount1);
1489 // Render some text with the shared atlas backend
1490 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1491 application.SendNotification();
1492 application.Render(2000);
1494 unsigned int actorCount1 = label.GetChildCount();
1495 tet_printf("Actor count after scrolling is(%d)\n", actorCount1);
1497 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1500 application.SendNotification();
1501 application.Render();
1503 unsigned int actorCount2 = label.GetChildCount();
1504 tet_printf("After changing color the actor count is(%d)\n", actorCount2);
1506 DALI_TEST_EQUALS(actorCount1, actorCount2, TEST_LOCATION);
1510 tet_result(TET_FAIL);
1516 int UtcDaliToolkitTextlabelScrollingN(void)
1518 ToolkitTestApplication application;
1519 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1521 TextLabel label = TextLabel::New("Some text to scroll");
1522 DALI_TEST_CHECK(label);
1524 application.GetScene().Add(label);
1526 // Avoid a crash when core load gl resources.
1527 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1529 // The text scrolling works only on single line text.
1530 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1532 // Turn on all the effects.
1533 label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1534 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1535 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1537 // Enable the auto scrolling effect.
1538 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1540 // The auto scrolling shouldn't be enabled.
1541 const bool enabled = label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>();
1542 DALI_TEST_CHECK(!enabled);
1544 label.SetProperty(TextLabel::Property::MULTI_LINE, false);
1545 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 1);
1546 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 9999.0f);
1547 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1552 application.SendNotification();
1553 application.Render(1000);
1555 application.GetScene().Remove(label);
1556 application.SendNotification();
1557 application.Render();
1559 DALI_TEST_CHECK(!label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
1561 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1562 application.GetScene().Add(label);
1564 application.SendNotification();
1565 application.Render();
1567 DALI_TEST_CHECK(label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
1569 label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, (Toolkit::TextLabel::AutoScrollStopMode::Type)2); // invalid type
1570 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1572 application.SendNotification();
1573 application.Render();
1575 DALI_TEST_CHECK(label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
1579 tet_result(TET_FAIL);
1585 int UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
1587 ToolkitTestApplication application;
1588 tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
1590 TextLabel label = TextLabel::New("Some text to scroll");
1591 DALI_TEST_CHECK(label);
1593 application.GetScene().Add(label);
1595 // Avoid a crash when core load gl resources.
1596 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1598 // Turn on all the effects.
1599 label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1600 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1601 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1605 // Enable the auto scrolling effect.
1606 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1607 label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1609 // Disable the ellipsis
1610 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
1613 application.SendNotification();
1614 application.Render();
1616 // Stop auto scrolling
1617 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1619 // Check the ellipsis property
1620 DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
1624 tet_result(TET_FAIL);
1630 int UtcDaliToolkitTextlabelEllipsis(void)
1632 ToolkitTestApplication application;
1633 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1635 TextLabel label = TextLabel::New("Hello world");
1636 DALI_TEST_CHECK(label);
1638 // Avoid a crash when core load gl resources.
1639 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1641 application.GetScene().Add(label);
1643 // Turn on all the effects
1644 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1645 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1646 label.SetProperty(Actor::Property::SIZE, Vector2(360.0f, 10.f));
1651 application.SendNotification();
1652 application.Render();
1656 tet_result(TET_FAIL);
1659 label.SetProperty(TextLabel::Property::TEXT, "Hello world ");
1660 label.SetProperty(DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false);
1661 label.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 10.f));
1666 application.SendNotification();
1667 application.Render();
1671 tet_result(TET_FAIL);
1674 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1675 label.SetProperty(DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
1676 label.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 10.f));
1681 application.SendNotification();
1682 application.Render();
1686 tet_result(TET_FAIL);
1692 int UtcDaliToolkitTextlabelTextWrapMode(void)
1694 ToolkitTestApplication application;
1695 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1699 TextLabel label = TextLabel::New();
1700 label.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.f));
1701 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1702 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1704 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1705 application.GetScene().Add(label);
1707 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "WORD");
1708 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
1710 application.SendNotification();
1711 application.Render();
1713 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1714 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1716 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
1717 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1719 application.SendNotification();
1720 application.Render();
1722 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD);
1723 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
1725 application.SendNotification();
1726 application.Render();
1728 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1729 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1731 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER);
1732 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1734 application.SendNotification();
1735 application.Render();
1737 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1738 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1740 tet_infoline("Ensure invalid string does not change wrapping mode");
1741 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode");
1742 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1747 int UtcDaliToolkitTextLabelColorComponents(void)
1749 ToolkitTestApplication application;
1751 TextLabel label = TextLabel::New();
1752 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1753 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 1.0f, TEST_LOCATION);
1754 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 0.0f, TEST_LOCATION);
1755 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 0.0f, TEST_LOCATION);
1756 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1758 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::GREEN);
1759 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 0.0f, TEST_LOCATION);
1760 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 1.0f, TEST_LOCATION);
1761 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 0.0f, TEST_LOCATION);
1762 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1764 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLUE);
1765 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 0.0f, TEST_LOCATION);
1766 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 0.0f, TEST_LOCATION);
1767 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 1.0f, TEST_LOCATION);
1768 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1770 label.SetProperty(TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f);
1771 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 0.6f, TEST_LOCATION);
1772 DALI_TEST_EQUALS(label.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR), Vector4(0.0f, 0.0f, 1.0f, 0.6f), TEST_LOCATION);
1774 // Test a transparent text - Rendering should be skipped.
1775 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1776 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLUE);
1778 application.GetScene().Add(label);
1780 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1781 drawTrace.Enable(true);
1783 application.SendNotification();
1784 application.Render();
1786 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION); // Should be rendered
1788 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT);
1792 application.SendNotification();
1793 application.Render();
1795 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), false, TEST_LOCATION); // Rendering should be skipped
1797 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1801 application.SendNotification();
1802 application.Render();
1804 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION); // Should be rendered again
1809 int UtcDaliToolkitTextlabelTextStyle01(void)
1811 ToolkitTestApplication application;
1812 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1814 TextLabel label = TextLabel::New();
1815 label.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.f));
1816 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1817 label.SetProperty(TextLabel::Property::POINT_SIZE, 12);
1818 application.GetScene().Add(label);
1820 Property::Map outlineMapSet;
1821 Property::Map outlineMapGet;
1823 outlineMapSet["color"] = Color::BLUE;
1824 outlineMapSet["width"] = 2.0f;
1825 outlineMapSet["offset"] = "2 2";
1826 outlineMapSet["blurRadius"] = "3";
1827 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
1829 application.SendNotification();
1830 application.Render();
1832 Property::Map shadowMapSet;
1833 shadowMapSet.Insert("color", "green");
1834 shadowMapSet.Insert("offset", "2 2");
1835 shadowMapSet.Insert("blurRadius", "3");
1836 label.SetProperty(TextLabel::Property::SHADOW, shadowMapSet);
1838 outlineMapSet["color"] = Color::RED;
1839 outlineMapSet["width"] = 0.0f;
1840 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
1842 application.SendNotification();
1843 application.Render();
1845 outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
1847 Property::Value* colorValue = outlineMapGet.Find("color");
1849 bool colorMatched(false);
1853 Property::Type valueType = colorValue->GetType();
1855 if(Property::STRING == valueType)
1857 std::string stringValue;
1858 colorValue->Get(stringValue);
1859 if(stringValue == "red")
1861 colorMatched = true;
1864 else if(Property::VECTOR4 == valueType)
1866 Vector4 colorVector4;
1867 colorValue->Get(colorVector4);
1868 if(colorVector4 == Color::RED)
1870 colorMatched = true;
1875 DALI_TEST_EQUALS(colorMatched, true, TEST_LOCATION);
1880 int UtcDaliToolkitTextlabelMultiline(void)
1882 ToolkitTestApplication application;
1883 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1885 TextLabel label = TextLabel::New();
1886 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world");
1887 label.SetProperty(TextLabel::Property::POINT_SIZE, 20);
1888 label.SetProperty(TextLabel::Property::MULTI_LINE, false);
1889 application.GetScene().Add(label);
1891 application.SendNotification();
1892 application.Render();
1894 int lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1895 DALI_TEST_EQUALS(lineCount, 1, TEST_LOCATION);
1897 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1899 application.SendNotification();
1900 application.Render();
1902 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1903 DALI_TEST_EQUALS(true, (lineCount > 1), TEST_LOCATION);
1908 int UtcDaliToolkitTextlabelTextDirection(void)
1910 ToolkitTestApplication application;
1911 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1913 TextLabel label = TextLabel::New();
1914 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT), TEST_LOCATION);
1916 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1917 label.SetProperty(TextLabel::Property::POINT_SIZE, 20);
1918 label.SetProperty(DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
1919 application.GetScene().Add(label);
1922 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT), TEST_LOCATION);
1925 label.SetProperty(TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ");
1926 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1928 // Test RTL text starting with weak character
1929 label.SetProperty(TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ");
1930 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1932 // Test RTL text string with emoji and weak character
1933 label.SetProperty(TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ");
1934 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1939 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1941 ToolkitTestApplication application;
1942 tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1944 TextLabel label = TextLabel::New();
1946 label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP);
1947 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1948 label.SetProperty(TextLabel::Property::POINT_SIZE, 15);
1949 label.SetProperty(TextLabel::Property::LINE_SPACING, 12);
1950 application.GetScene().Add(label);
1951 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::TOP), TEST_LOCATION);
1953 label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE);
1954 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::MIDDLE), TEST_LOCATION);
1956 label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM);
1957 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::BOTTOM), TEST_LOCATION);
1962 int UtcDaliToolkitTextLabelBitmapFont(void)
1964 ToolkitTestApplication application;
1965 tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1967 DevelText::BitmapFontDescription fontDescription;
1968 fontDescription.name = "Digits";
1969 fontDescription.underlinePosition = 0.f;
1970 fontDescription.underlineThickness = 0.f;
1972 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f});
1973 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f});
1974 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f});
1975 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f});
1976 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f});
1977 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f});
1978 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f});
1979 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f});
1980 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f});
1981 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f});
1982 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f});
1984 TextAbstraction::BitmapFont bitmapFont;
1985 DevelText::CreateBitmapFont(fontDescription, bitmapFont);
1987 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1988 fontClient.GetFontId(bitmapFont);
1990 TextLabel label = TextLabel::New();
1992 label.SetProperty(TextLabel::Property::TEXT, "0123456789:");
1993 label.SetProperty(TextLabel::Property::FONT_FAMILY, "Digits");
1995 // 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.
1996 DALI_TEST_EQUALS(label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1998 application.GetScene().Add(label);
2000 application.SendNotification();
2001 application.Render();
2003 // The text has been rendered if the height of the text-label is the height of the line.
2004 DALI_TEST_EQUALS(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2009 int ConvertPointToPixel(float point)
2011 unsigned int horizontalDpi = 0u;
2012 unsigned int verticalDpi = 0u;
2013 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2014 fontClient.GetDpi(horizontalDpi, verticalDpi);
2016 return (point * 72.f) / static_cast<float>(horizontalDpi);
2019 int UtcDaliToolkitTextlabelTextFit(void)
2021 ToolkitTestApplication application;
2022 tet_infoline(" UtcDaliToolkitTextlabelTextFit");
2023 TextLabel label = TextLabel::New();
2024 Vector2 size(460.0f, 100.0f);
2025 label.SetProperty(Actor::Property::SIZE, size);
2026 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
2028 // connect to the text git changed signal.
2029 ConnectionTracker* testTracker = new ConnectionTracker();
2030 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2031 bool textFitChangedSignal = false;
2032 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2033 gTextFitChangedCallBackCalled = false;
2036 Property::Map textFitMapSet;
2037 textFitMapSet["enable"] = true;
2038 textFitMapSet["minSize"] = 10.f;
2039 textFitMapSet["maxSize"] = 100.f;
2040 textFitMapSet["stepSize"] = -1.f;
2041 textFitMapSet["fontSizeType"] = "pointSize";
2043 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2044 label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2046 application.GetScene().Add(label);
2048 application.SendNotification();
2049 application.Render();
2051 const Vector3 EXPECTED_NATURAL_SIZE(448.0f, 96.0f, 0.0f);
2052 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2054 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2055 DALI_TEST_CHECK(textFitChangedSignal);
2058 textFitMapSet.Clear();
2059 textFitMapSet["enable"] = true;
2060 textFitMapSet["minSize"] = ConvertPointToPixel(10.f);
2061 textFitMapSet["maxSize"] = ConvertPointToPixel(100.f);
2062 textFitMapSet["stepSize"] = ConvertPointToPixel(1.f);
2063 textFitMapSet["fontSizeType"] = "pixelSize";
2065 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2067 application.SendNotification();
2068 application.Render();
2070 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2075 int UtcDaliToolkitTextlabelTextFitStressTest(void)
2077 ToolkitTestApplication application;
2078 tet_infoline(" UtcDaliToolkitTextlabelTextFitStressTest");
2079 TextLabel label = TextLabel::New();
2080 Vector2 size(460.0f, 100.0f);
2081 label.SetProperty(Actor::Property::SIZE, size);
2082 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
2084 // connect to the text git changed signal.
2085 ConnectionTracker* testTracker = new ConnectionTracker();
2086 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2087 bool textFitChangedSignal = false;
2088 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2089 gTextFitChangedCallBackCalled = false;
2091 // check point size with veryvery big range
2092 Property::Map textFitMapSet;
2093 textFitMapSet["enable"] = true;
2094 textFitMapSet["minSize"] = 10.f;
2095 textFitMapSet["maxSize"] = 10000.f;
2096 textFitMapSet["stepSize"] = -1.0f;
2097 textFitMapSet["fontSizeType"] = "pointSize";
2099 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2100 label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2102 application.GetScene().Add(label);
2104 application.SendNotification();
2105 application.Render();
2107 const Vector3 EXPECTED_NATURAL_SIZE(448.0f, 96.0f, 0.0f);
2108 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2110 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2111 DALI_TEST_CHECK(textFitChangedSignal);
2116 int UtcDaliToolkitTextlabelFastTextFitStressTest(void)
2118 ToolkitTestApplication application;
2119 tet_infoline(" UtcDaliToolkitTextlabelFastTextFitStressTest");
2120 TextLabel label = TextLabel::New();
2121 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
2122 label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2124 // connect to the text git changed signal.
2125 ConnectionTracker* testTracker = new ConnectionTracker();
2126 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2127 bool textFitChangedSignal = false;
2128 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2129 gTextFitChangedCallBackCalled = false;
2131 application.GetScene().Add(label);
2133 // check text label width at range [100, 299]
2134 for(int i=100; i<300; i++)
2136 Vector2 size((float)i, 200.f);
2137 label.SetProperty(Actor::Property::SIZE, size);
2139 // check point size with veryvery big range
2140 Property::Map textFitMapSet;
2141 textFitMapSet["enable"] = true;
2142 textFitMapSet["minSize"] = 10.f;
2143 textFitMapSet["maxSize"] = 10000.f;
2144 textFitMapSet["stepSize"] = -1.0f;
2145 textFitMapSet["fontSizeType"] = "pointSize";
2147 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2149 application.SendNotification();
2150 application.Render();
2153 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2154 DALI_TEST_CHECK(textFitChangedSignal);
2159 int UtcDaliToolkitTextlabelTextFitMultiLine(void)
2161 ToolkitTestApplication application;
2162 tet_infoline(" UtcDaliToolkitTextlabelTextFitMultiLine");
2163 TextLabel label = TextLabel::New();
2164 Vector2 size(500.0f, 100.0f);
2165 label.SetProperty(Actor::Property::SIZE, size);
2166 label.SetProperty(TextLabel::Property::TEXT, "Hello world\nHello world");
2167 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2169 // connect to the text git changed signal.
2170 ConnectionTracker* testTracker = new ConnectionTracker();
2171 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2172 bool textFitChangedSignal = false;
2173 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2174 gTextFitChangedCallBackCalled = false;
2176 Property::Map textFitMapSet;
2177 textFitMapSet["enable"] = true;
2178 textFitMapSet["minSize"] = 10.f;
2179 textFitMapSet["maxSize"] = 100.f;
2180 textFitMapSet["stepSize"] = -1.0f;
2181 textFitMapSet["fontSizeType"] = "pointSize";
2183 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2184 label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2186 application.GetScene().Add(label);
2188 application.SendNotification();
2189 application.Render();
2191 float textFitFontSize = (label.GetProperty(Dali::Toolkit::DevelTextLabel::Property::TEXT_FIT).Get<Property::Map>())["fontSize"].Get<float>();
2192 DALI_TEST_EQUALS(textFitFontSize, 14.f, TEST_LOCATION);
2194 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2195 DALI_TEST_CHECK(textFitChangedSignal);
2200 int UtcDaliToolkitTextlabelTextFitArray(void)
2202 ToolkitTestApplication application;
2203 tet_infoline(" UtcDaliToolkitTextlabelTextFitArray");
2204 TextLabel label = TextLabel::New();
2205 Vector2 size(300.0f, 80.0f);
2206 label.SetProperty(Actor::Property::SIZE, size);
2207 label.SetProperty(TextLabel::Property::TEXT, "A Quick Brown Fox Jumps Over The Lazy Dog");
2208 label.SetProperty(DevelTextLabel::Property::MIN_LINE_SIZE, 80.f);
2209 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
2210 application.GetScene().Add(label);
2212 // make sorted options.
2213 std::vector<DevelTextLabel::FitOption> fitOptions;
2214 fitOptions.push_back(DevelTextLabel::FitOption(10, 12));
2215 fitOptions.push_back(DevelTextLabel::FitOption(8, 10));
2216 fitOptions.push_back(DevelTextLabel::FitOption(6, 8));
2217 fitOptions.push_back(DevelTextLabel::FitOption(4, 6));
2218 fitOptions.push_back(DevelTextLabel::FitOption(20, 22));
2219 fitOptions.push_back(DevelTextLabel::FitOption(22, 24));
2220 fitOptions.push_back(DevelTextLabel::FitOption(12, 14));
2222 DevelTextLabel::SetTextFitArray(label, true, fitOptions);
2224 application.SendNotification();
2225 application.Render();
2227 bool enable = Dali::Toolkit::DevelTextLabel::IsTextFitArrayEnabled(label);
2228 DALI_TEST_EQUALS(true, enable, TEST_LOCATION);
2230 std::vector<Dali::Toolkit::DevelTextLabel::FitOption> getFitOptions = Dali::Toolkit::DevelTextLabel::GetTextFitArray(label);
2231 size_t numberOfFitOptions = getFitOptions.size();
2232 DALI_TEST_EQUALS(7u, numberOfFitOptions, TEST_LOCATION);
2234 const Vector3 EXPECTED_NATURAL_SIZE(276.0f, 16.0f, 0.0f);
2235 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2237 std::vector<DevelTextLabel::FitOption> emptyFitOptions;
2238 DevelTextLabel::SetTextFitArray(label, false, emptyFitOptions);
2240 application.SendNotification();
2241 application.Render();
2243 enable = Dali::Toolkit::DevelTextLabel::IsTextFitArrayEnabled(label);
2244 DALI_TEST_EQUALS(false, enable, TEST_LOCATION);
2246 const Vector3 EXPECTED_NATURAL_SIZE_DISABLE(690.0f, 80.0f, 0.0f);
2247 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE_DISABLE, label.GetNaturalSize(), TEST_LOCATION);
2249 // make unsorted options.
2250 std::vector<DevelTextLabel::FitOption> unorderedFitOptions;
2251 unorderedFitOptions.push_back(DevelTextLabel::FitOption(4, 6));
2252 unorderedFitOptions.push_back(DevelTextLabel::FitOption(6, 8));
2253 unorderedFitOptions.push_back(DevelTextLabel::FitOption(8, 10));
2254 unorderedFitOptions.push_back(DevelTextLabel::FitOption(10, 8));
2256 DevelTextLabel::SetTextFitArray(label, true, unorderedFitOptions);
2258 application.SendNotification();
2259 application.Render();
2261 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2266 int UtcDaliToolkitTextlabelMaxTextureSet(void)
2268 ToolkitTestApplication application;
2269 tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
2271 DevelText::BitmapFontDescription fontDescription;
2272 fontDescription.name = "Digits";
2273 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f});
2275 TextAbstraction::BitmapFont bitmapFont;
2276 DevelText::CreateBitmapFont(fontDescription, bitmapFont);
2278 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2279 fontClient.GetFontId(bitmapFont);
2281 TextLabel label = TextLabel::New();
2282 label.SetProperty(TextLabel::Property::FONT_FAMILY, "Digits");
2283 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2284 label.SetProperty(TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded.");
2285 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2286 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2288 Property::Map underlineMapSet;
2289 underlineMapSet.Clear();
2290 underlineMapSet.Insert("enable", true);
2291 underlineMapSet.Insert("color", Color::RED);
2292 underlineMapSet.Insert("height", 1);
2293 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2294 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2296 Property::Map strikethroughMapSet;
2297 strikethroughMapSet.Clear();
2298 strikethroughMapSet.Insert("enable", true);
2299 strikethroughMapSet.Insert("color", Color::RED);
2300 strikethroughMapSet.Insert("height", 2.0f);
2301 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2302 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2304 application.GetScene().Add(label);
2306 application.SendNotification();
2307 application.Render();
2309 const int maxTextureSize = Dali::GetMaxTextureSize();
2310 // Whether the rendered text is greater than maxTextureSize
2311 DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2313 // Check if the number of renderers is greater than 1.
2314 DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2317 underlineMapSet.Clear();
2318 underlineMapSet.Insert("enable", false);
2319 underlineMapSet.Insert("color", Color::BLUE);
2320 underlineMapSet.Insert("height", 0);
2321 underlineMapSet.Insert("type", Text::Underline::DASHED);
2322 underlineMapSet.Insert("dashWidth", 2);
2323 underlineMapSet.Insert("dashGap", 1);
2324 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2325 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2327 application.GetScene().Add(label);
2329 application.SendNotification();
2330 application.Render();
2332 // Whether the rendered text is greater than maxTextureSize
2333 DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2335 // Check if the number of renderers is greater than 1.
2336 DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2339 underlineMapSet.Clear();
2340 underlineMapSet.Insert("enable", false);
2341 underlineMapSet.Insert("color", Color::BLUE);
2342 underlineMapSet.Insert("height", 0);
2343 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
2344 underlineMapSet.Insert("dashWidth", 2);
2345 underlineMapSet.Insert("dashGap", 1);
2346 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2347 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2349 application.GetScene().Add(label);
2351 application.SendNotification();
2352 application.Render();
2354 // Whether the rendered text is greater than maxTextureSize
2355 DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2357 // Check if the number of renderers is greater than 1.
2358 DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2360 // Coverage test for case of layoutSize is bigger than maxTextureSize
2361 float max_value = static_cast<float>(std::numeric_limits<uint16_t>::max());
2362 label.SetProperty(Actor::Property::SIZE, Vector2(max_value, 30.0f));
2363 application.SendNotification();
2364 application.Render();
2369 int UtcDaliToolkitTextlabelStrikethroughExceedsWidthAndHeight(void)
2371 ToolkitTestApplication application;
2372 tet_infoline(" UtcDaliToolkitTextlabelStrikethroughExceedsWidthAndHeight");
2374 TextLabel label = TextLabel::New();
2375 label.SetProperty(TextLabel::Property::TEXT, "Test");
2376 label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2377 //Exeeding BufferWidth
2378 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 400.0f));
2379 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2380 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2382 application.GetScene().Add(label);
2383 application.SendNotification();
2384 application.Render();
2386 Property::Map strikethroughMapSet;
2387 strikethroughMapSet.Clear();
2388 strikethroughMapSet.Insert("enable", true);
2389 strikethroughMapSet.Insert("color", Color::BLUE);
2390 strikethroughMapSet.Insert("height", 2.0f);
2391 label.SetProperty(TextLabel::Property::TEXT, "Test1");
2392 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2393 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2394 application.GetScene().Add(label);
2395 application.SendNotification();
2396 application.Render();
2397 // Check if the number of renderers is 1.
2398 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2400 label = TextLabel::New();
2401 label.SetProperty(TextLabel::Property::TEXT, "Test");
2402 label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2404 //Exeeding BufferHeight
2405 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.0f));
2406 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2407 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2409 application.GetScene().Add(label);
2410 application.SendNotification();
2411 application.Render();
2413 strikethroughMapSet.Clear();
2414 strikethroughMapSet.Insert("enable", true);
2415 strikethroughMapSet.Insert("color", Color::BLUE);
2416 strikethroughMapSet.Insert("height", 2.0f);
2417 label.SetProperty(TextLabel::Property::TEXT, "Test2");
2418 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2419 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2420 application.GetScene().Add(label);
2421 application.SendNotification();
2422 application.Render();
2423 // Check if the number of renderers is 1.
2424 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2429 int UtcDaliToolkitTextlabelUnderlineExceedsWidth(void)
2431 ToolkitTestApplication application;
2432 tet_infoline(" UtcDaliToolkitTextlabelUnderlineExceedsWidth");
2434 TextLabel label = TextLabel::New();
2435 label.SetProperty(TextLabel::Property::TEXT, "Test");
2436 label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2437 //Exeeding BufferWidth
2438 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 400.0f));
2439 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2440 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2442 application.GetScene().Add(label);
2443 application.SendNotification();
2444 application.Render();
2446 Property::Map underlineMapSet;
2449 underlineMapSet.Clear();
2450 underlineMapSet.Insert("enable", true);
2451 underlineMapSet.Insert("color", Color::BLUE);
2452 underlineMapSet.Insert("height", 1);
2453 underlineMapSet.Insert("type", Text::Underline::SOLID);
2454 underlineMapSet.Insert("dashWidth", 2);
2455 underlineMapSet.Insert("dashGap", 1);
2456 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2457 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2459 application.GetScene().Add(label);
2461 application.SendNotification();
2462 application.Render();
2464 // Check if the number of renderers is 1.
2465 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2468 underlineMapSet.Clear();
2469 underlineMapSet.Insert("enable", true);
2470 underlineMapSet.Insert("color", Color::BLUE);
2471 underlineMapSet.Insert("height", 1);
2472 underlineMapSet.Insert("type", Text::Underline::DASHED);
2473 underlineMapSet.Insert("dashWidth", 2);
2474 underlineMapSet.Insert("dashGap", 1);
2475 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2476 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2478 application.GetScene().Add(label);
2480 application.SendNotification();
2481 application.Render();
2483 // Check if the number of renderers is 1.
2484 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2487 underlineMapSet.Clear();
2488 underlineMapSet.Insert("enable", true);
2489 underlineMapSet.Insert("color", Color::BLUE);
2490 underlineMapSet.Insert("height", 1);
2491 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
2492 underlineMapSet.Insert("dashWidth", 2);
2493 underlineMapSet.Insert("dashGap", 1);
2494 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2495 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2497 application.GetScene().Add(label);
2499 application.SendNotification();
2500 application.Render();
2502 // Check if the number of renderers is 1.
2503 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2508 int UtcDaliToolkitTextlabelLastCharacterIndex(void)
2510 ToolkitTestApplication application;
2511 tet_infoline(" UtcDaliToolkitTextlabelLastCharacterIndex");
2513 Vector2 size(300.0f, 100.0f);
2515 Dali::Toolkit::DevelText::RendererParameters textParameters;
2516 textParameters.text = "This is a sample text to get the last index.";
2517 textParameters.layout = "multiLine";
2518 textParameters.fontSize = 20.f;
2519 textParameters.textWidth = 300u;
2520 textParameters.textHeight = 100u;
2521 textParameters.ellipsisEnabled = true;
2522 Dali::Property::Array indexArray = Dali::Toolkit::DevelText::GetLastCharacterIndex(textParameters);
2524 DALI_TEST_CHECK(!indexArray.Empty());
2525 DALI_TEST_EQUALS(indexArray.GetElementAt(0).Get<int>(), 10, TEST_LOCATION);
2530 int UtcDaliToolkitTextlabelFontSizeScale(void)
2532 ToolkitTestApplication application;
2533 tet_infoline(" UtcDaliToolkitTextlabelFontSizeScale");
2535 TextLabel label = TextLabel::New();
2536 label.SetProperty(TextLabel::Property::POINT_SIZE, 30.f);
2537 label.SetProperty(TextLabel::Property::TEXT, "Test");
2538 Vector3 nonScaledSize = label.GetNaturalSize();
2540 TextLabel labelScaled = TextLabel::New();
2541 labelScaled.SetProperty(TextLabel::Property::POINT_SIZE, 15.f);
2542 labelScaled.SetProperty(Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f);
2543 labelScaled.SetProperty(TextLabel::Property::TEXT, "Test");
2544 Vector3 scaledSize = labelScaled.GetNaturalSize();
2546 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
2548 label.SetProperty(TextLabel::Property::PIXEL_SIZE, 30.f);
2549 label.SetProperty(TextLabel::Property::TEXT, "Test");
2550 nonScaledSize = label.GetNaturalSize();
2552 labelScaled.SetProperty(TextLabel::Property::PIXEL_SIZE, 15.f);
2553 labelScaled.SetProperty(Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f);
2554 labelScaled.SetProperty(TextLabel::Property::TEXT, "Test");
2555 scaledSize = labelScaled.GetNaturalSize();
2557 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
2562 int UtcDaliToolkitTextlabelAnchorColor(void)
2564 ToolkitTestApplication application;
2565 tet_infoline(" UtcDaliToolkitTextlabelAnchorColor");
2566 TextLabel label = TextLabel::New();
2567 DALI_TEST_CHECK(label);
2569 application.GetScene().Add(label);
2571 // connect to the anchor clicked signal.
2572 ConnectionTracker* testTracker = new ConnectionTracker();
2573 DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
2574 bool anchorClickedSignal = false;
2575 label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
2577 gAnchorClickedCallBackCalled = false;
2578 label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
2579 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2580 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2581 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2582 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2584 // Check that anchor color can be properly set
2585 label.SetProperty(DevelTextLabel::Property::ANCHOR_COLOR, Color::BLUE);
2586 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_COLOR), Color::BLUE, TEST_LOCATION);
2588 label.SetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR, Color::RED);
2589 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR), Color::RED, TEST_LOCATION);
2591 application.SendNotification();
2592 application.Render();
2594 // Create a tap event to touch the text label.
2595 TestGenerateTap(application, 5.0f, 25.0f, 100);
2596 application.SendNotification();
2597 application.Render();
2599 // Update clicked color
2600 label.SetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR, Color::BLUE);
2601 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR), Color::BLUE, TEST_LOCATION);
2603 application.SendNotification();
2604 application.Render();
2606 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2607 DALI_TEST_CHECK(anchorClickedSignal);
2612 // Positive test for the anchorClicked signal.
2613 int UtcDaliToolkitTextlabelAnchorClicked(void)
2615 ToolkitTestApplication application;
2616 tet_infoline(" UtcDaliToolkitTextlabelAnchorClicked");
2617 TextLabel label = TextLabel::New();
2618 DALI_TEST_CHECK(label);
2620 application.GetScene().Add(label);
2622 // connect to the anchor clicked signal.
2623 ConnectionTracker* testTracker = new ConnectionTracker();
2624 DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
2625 bool anchorClickedSignal = false;
2626 label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
2628 gAnchorClickedCallBackCalled = false;
2629 label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
2630 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2631 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2632 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2633 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2635 application.SendNotification();
2636 application.Render();
2638 // Create a tap event to touch the text label.
2639 TestGenerateTap(application, 5.0f, 25.0f, 100);
2640 application.SendNotification();
2641 application.Render();
2643 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2644 DALI_TEST_CHECK(anchorClickedSignal);
2647 gAnchorClickedCallBackCalled = false;
2648 anchorClickedSignal = false;
2649 label.SetProperty(TextLabel::Property::TEXT, "");
2650 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, false);
2652 application.SendNotification();
2653 application.Render();
2656 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2657 label.SetProperty(TextLabel::Property::TEXT, "<a color='red' clicked-color='green' href='https://www.tizen.org'>TIZEN</a>");
2658 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2659 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2660 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2662 application.SendNotification();
2663 application.Render();
2665 // Create a tap event to touch the text label.
2666 TestGenerateTap(application, 5.0f, 25.0f, 200);
2667 application.SendNotification();
2668 application.Render();
2670 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2671 DALI_TEST_CHECK(anchorClickedSignal);
2673 gAnchorClickedCallBackNotCalled = true;
2674 // Tap the outside of anchor, callback should not be called.
2675 TestGenerateTap(application, 150.f, 100.f, 300);
2676 application.SendNotification();
2677 application.Render();
2679 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
2684 int UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize(void)
2686 ToolkitTestApplication application;
2687 tet_infoline(" UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize ");
2689 //TextLabel is not using Atlas but this is to unify font-size on text-controllers
2691 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
2692 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
2693 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
2695 // Create a text editor
2696 TextLabel textLabel = TextLabel::New();
2697 //Set size to avoid automatic eliding
2698 textLabel.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
2699 //Set very large font-size using point-size
2700 textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 1000);
2701 //Specify font-family
2702 textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2703 //Set text to check if appear or not
2704 textLabel.SetProperty(TextLabel::Property::TEXT, "A");
2706 application.GetScene().Add(textLabel);
2708 application.SendNotification();
2709 application.Render();
2710 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
2711 Vector3 naturalSize = textLabel.GetNaturalSize();
2713 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
2714 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
2719 int UtcDaliTextLabelHyphenWrapMode(void)
2721 ToolkitTestApplication application;
2722 tet_infoline(" UtcDaliTextLabelHyphenWrapMode ");
2725 TextLabel label = TextLabel::New();
2726 label.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
2727 label.SetProperty(TextLabel::Property::POINT_SIZE, 12.f);
2728 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2729 application.GetScene().Add(label);
2730 application.SendNotification();
2731 application.Render();
2733 label.SetProperty(TextLabel::Property::TEXT, "Hi Experimen");
2734 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
2735 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::HYPHENATION), TEST_LOCATION);
2737 application.SendNotification();
2738 application.Render();
2740 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2746 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
2748 label.SetProperty(TextLabel::Property::TEXT, "Hi Experimen");
2749 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
2750 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::MIXED), TEST_LOCATION);
2752 application.SendNotification();
2753 application.Render();
2755 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2762 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
2767 int utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged(void)
2769 ToolkitTestApplication application;
2771 tet_infoline(" utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged ");
2773 int lineCountBefore = 0;
2774 int lineCountAfter = 0;
2776 // Create a text editor
2777 TextLabel textLabel = TextLabel::New();
2778 //Set very large font-size using point-size
2779 textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 10);
2780 //Specify font-family
2781 textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2783 textLabel.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.f));
2784 //Set text longer than width of textLabel
2785 textLabel.SetProperty(TextLabel::Property::TEXT, "Short text");
2786 //Set line wrap mode Character
2787 textLabel.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
2788 textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
2790 application.GetScene().Add(textLabel);
2792 application.SendNotification();
2793 application.Render();
2795 lineCountBefore = textLabel.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2797 textLabel.SetProperty(TextLabel::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
2798 lineCountAfter = textLabel.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2800 // When the text changed, the Line-count should be updated according to new text.
2801 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
2802 DALI_TEST_EQUALS(lineCountBefore, 1, TEST_LOCATION);
2803 DALI_TEST_GREATER(lineCountAfter, 1, TEST_LOCATION);
2808 int utcDaliTextLabelGeometryRTL(void)
2810 ToolkitTestApplication application;
2811 tet_infoline(" utcDaliTextLabelGeometryRTL");
2813 TextLabel label = TextLabel::New();
2814 DALI_TEST_CHECK(label);
2816 application.GetScene().Add(label);
2818 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2819 label.SetProperty(Actor::Property::SIZE, Vector2(150.f, 100.f));
2820 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2821 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2822 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2823 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2824 label.SetProperty(TextLabel::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر");
2825 // Avoid a crash when core load gl resources.
2826 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2828 // Render and notify
2829 application.SendNotification();
2830 application.Render();
2832 unsigned int expectedCount = 4;
2833 unsigned int startIndex = 3;
2834 unsigned int endIndex = 24;
2836 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2837 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2839 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2840 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2842 Vector<Vector2> expectedSizes;
2843 Vector<Vector2> expectedPositions;
2845 expectedPositions.PushBack(Vector2(25, 0));
2846 expectedSizes.PushBack(Vector2(34, 25));
2848 expectedPositions.PushBack(Vector2(-1, 25));
2849 expectedSizes.PushBack(Vector2(53, 25));
2851 expectedPositions.PushBack(Vector2(-1, 50));
2852 expectedSizes.PushBack(Vector2(60, 25));
2854 expectedPositions.PushBack(Vector2(75, 75));
2855 expectedSizes.PushBack(Vector2(37, 25));
2857 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2862 int utcDaliTextLabelGeometryGlyphMiddle(void)
2864 ToolkitTestApplication application;
2865 tet_infoline(" utcDaliTextLabelGeometryGlyphMiddle");
2867 TextLabel label = TextLabel::New();
2868 DALI_TEST_CHECK(label);
2870 application.GetScene().Add(label);
2872 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2873 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2874 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2875 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2876 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2877 label.SetProperty(TextLabel::Property::TEXT, "لا تحتوي على لا");
2879 // Avoid a crash when core load gl resources.
2880 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2882 // Render and notify
2883 application.SendNotification();
2884 application.Render();
2886 unsigned int expectedCount = 1;
2887 unsigned int startIndex = 1;
2888 unsigned int endIndex = 13;
2890 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2891 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2893 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2894 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2896 Vector<Vector2> expectedSizes;
2897 Vector<Vector2> expectedPositions;
2899 expectedPositions.PushBack(Vector2(6, 0));
2900 expectedSizes.PushBack(Vector2(125, 25));
2902 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2907 int utcDaliTextLabelGeometryOneGlyph(void)
2909 ToolkitTestApplication application;
2910 tet_infoline(" utcDaliTextLabelGeometryOneGlyph ");
2912 TextLabel label = TextLabel::New();
2913 DALI_TEST_CHECK(label);
2915 application.GetScene().Add(label);
2917 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2918 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2919 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2920 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2921 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2922 label.SetProperty(TextLabel::Property::TEXT, "H");
2924 // Avoid a crash when core load gl resources.
2925 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2927 // Render and notify
2928 application.SendNotification();
2929 application.Render();
2931 unsigned int expectedCount = 1;
2932 unsigned int startIndex = 0;
2933 unsigned int endIndex = 0;
2935 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2936 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2938 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2939 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2941 Vector<Vector2> expectedSizes;
2942 Vector<Vector2> expectedPositions;
2944 expectedPositions.PushBack(Vector2(-2, 0));
2945 expectedSizes.PushBack(Vector2(16, 25));
2947 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2949 positionsList.Clear();
2955 positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2956 sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2958 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2963 int utcDaliTextLabelGeometryNullPtr(void)
2965 ToolkitTestApplication application;
2966 tet_infoline("utcDaliTextLabelGeometryNullPtr");
2968 TextLabel label = TextLabel::New();
2969 DALI_TEST_CHECK(label);
2971 application.GetScene().Add(label);
2973 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2974 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2975 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2976 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2977 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2978 label.SetProperty(TextLabel::Property::TEXT, "");
2980 // Avoid a crash when core load gl resources.
2981 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2983 unsigned int expectedCount = 0;
2984 unsigned int startIndex = 0;
2985 unsigned int endIndex = 0;
2987 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2988 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2990 // Render and notify
2991 application.SendNotification();
2992 application.Render();
2994 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2995 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
3000 int UtcDaliToolkitTextlabelEllipsisPositionProperty(void)
3002 ToolkitTestApplication application;
3003 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty ");
3004 TextLabel textLabel = TextLabel::New();
3006 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Default is END");
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");
3010 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::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");
3014 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::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");
3018 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::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 integer");
3022 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 1);
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 integer");
3026 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 2);
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 integer");
3030 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 0);
3031 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3033 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
3034 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "START");
3035 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3037 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
3038 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "MIDDLE");
3039 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3041 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
3042 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "END");
3043 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3045 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
3046 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "start");
3047 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3049 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
3050 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "middle");
3051 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3053 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
3054 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "end");
3055 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3060 int UtcDaliToolkitTextLabelStrikethroughGeneration(void)
3062 ToolkitTestApplication application;
3063 tet_infoline(" UtcDaliToolkitTextLabelStrikethroughGeneration");
3065 TextLabel textLabel = TextLabel::New();
3066 textLabel.SetProperty(TextLabel::Property::TEXT, "Test");
3067 textLabel.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
3068 textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3069 textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
3071 application.GetScene().Add(textLabel);
3072 application.SendNotification();
3073 application.Render();
3075 Property::Map strikethroughMapSet;
3076 Property::Map strikethroughMapGet;
3078 strikethroughMapSet.Insert("enable", true);
3079 strikethroughMapSet.Insert("color", Color::RED);
3080 strikethroughMapSet.Insert("height", 2.0f);
3082 // Check the strikethrough property
3083 textLabel.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
3084 strikethroughMapGet = textLabel.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
3085 textLabel.SetProperty(TextLabel::Property::TEXT, "Test1");
3086 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
3087 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
3089 // Render and notify
3090 application.SendNotification();
3091 application.Render();
3093 strikethroughMapSet.Clear();
3094 strikethroughMapGet.Clear();
3099 int UtcDaliToolkitTextLabelMarkupRelativeLineHeight(void)
3101 ToolkitTestApplication application;
3102 tet_infoline(" UtcDaliToolkitTextLabelMarkupRelativeLineHeight");
3104 TextLabel label = TextLabel::New();
3105 label.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3106 label.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3107 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3108 label.SetProperty(TextLabel::Property::TEXT, "line 1\nline 2\nline 3\nline 4\nline 5");
3109 label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3110 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
3111 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3113 TextLabel labelSingleLineParagraph = TextLabel::New();
3114 labelSingleLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3115 labelSingleLineParagraph.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3116 labelSingleLineParagraph.SetProperty(TextLabel::Property::MULTI_LINE, true);
3117 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");
3118 labelSingleLineParagraph.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3119 labelSingleLineParagraph.SetProperty(TextLabel::Property::ELLIPSIS, false);
3120 labelSingleLineParagraph.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3122 TextLabel labelMultiLineParagraph = TextLabel::New();
3123 labelMultiLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3124 labelMultiLineParagraph.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3125 labelMultiLineParagraph.SetProperty(TextLabel::Property::MULTI_LINE, true);
3126 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");
3127 labelMultiLineParagraph.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3128 labelMultiLineParagraph.SetProperty(TextLabel::Property::ELLIPSIS, false);
3129 labelMultiLineParagraph.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3131 application.GetScene().Add(label);
3132 application.GetScene().Add(labelSingleLineParagraph);
3133 application.GetScene().Add(labelMultiLineParagraph);
3134 application.SendNotification();
3135 application.Render();
3137 Vector3 naturalSize = label.GetNaturalSize();
3138 Vector3 relativeSingleNaturalSize = labelSingleLineParagraph.GetNaturalSize();
3139 Vector3 relativeMultiNaturalSize = labelMultiLineParagraph.GetNaturalSize();
3141 float lineSize = naturalSize.y / 5.0f; //total size/number of lines
3143 //no effect of relative line size for paragraph with single line
3144 DALI_TEST_EQUALS(naturalSize.y, relativeSingleNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3146 DALI_TEST_EQUALS(lineSize * 8.5f, relativeMultiNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3151 int UtcDaliToolkitTextLabelRelativeLineHeight(void)
3153 ToolkitTestApplication application;
3154 tet_infoline(" UtcDaliToolkitTextLabelRelativeLineHeight");
3156 TextLabel label = TextLabel::New();
3157 label.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3158 label.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3159 label.SetProperty(TextLabel::Property::TEXT, "Hello\nWorld");
3161 application.GetScene().Add(label);
3162 application.SendNotification();
3163 application.Render();
3165 Vector3 naturalSize = label.GetNaturalSize();
3167 label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 0.5f);
3169 application.SendNotification();
3170 application.Render();
3172 Vector3 relativeNaturalSize = label.GetNaturalSize();
3174 DALI_TEST_EQUALS(naturalSize.y, relativeNaturalSize.y, TEST_LOCATION);
3176 label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 2.0f);
3178 application.SendNotification();
3179 application.Render();
3181 relativeNaturalSize = label.GetNaturalSize();
3183 DALI_TEST_EQUALS(naturalSize.y * 2, relativeNaturalSize.y, TEST_LOCATION);
3187 int UtcDaliTextLabelCharacterSpacing(void)
3189 ToolkitTestApplication application;
3190 tet_infoline(" UtcDaliTextLabelCharacterSpacing ");
3192 TextLabel textLabel = TextLabel::New();
3194 textLabel.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
3196 application.GetScene().Add(textLabel);
3197 application.SendNotification();
3198 application.Render();
3200 textLabel.SetProperty(TextLabel::Property::TEXT, "Hi Experiment");
3201 textLabel.SetProperty(DevelTextLabel::Property::CHARACTER_SPACING, 10.f);
3202 DALI_TEST_EQUALS(textLabel.GetProperty<float>(DevelTextLabel::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3204 application.SendNotification();
3205 application.Render();
3210 int UtcDaliTextTextLabelSizeNegativeLineSpacing(void)
3212 ToolkitTestApplication application;
3213 tet_infoline("UtcDaliTextTextLabelSizeNegativeLineSpacing");
3215 TextLabel label = TextLabel::New();
3217 float lineSpacing = -20.f;
3219 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
3220 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
3221 label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
3222 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3223 label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
3225 application.GetScene().Add(label);
3226 application.SendNotification();
3227 application.Render();
3229 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, 0, 123);
3230 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, 0, 123);
3232 Vector2 lastLinePos = positionsList[positionsList.Size() - 1];
3233 Vector2 lastLineSize = sizeList[sizeList.Size() - 1];
3235 DALI_TEST_EQUALS(sizeList[0].y * (sizeList.Size() - 1), lastLinePos.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3236 DALI_TEST_EQUALS(sizeList[0].y - lineSpacing, lastLineSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3238 application.SendNotification();
3239 application.Render();
3244 int UtcDaliTextLabelNegativeLineSpacingWithEllipsis(void)
3246 ToolkitTestApplication application;
3247 tet_infoline("UtcDaliTextLabelNegativeLineSpacingWithEllipsis");
3249 TextLabel label = TextLabel::New();
3251 float lineSpacing = -20.f;
3253 label.SetProperty(Actor::Property::SIZE, Vector2(480.0f, 100.f));
3254 label.SetProperty(TextLabel::Property::POINT_SIZE, 11.0f);
3255 label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
3256 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3257 label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
3258 label.SetProperty(TextLabel::Property::ELLIPSIS, true);
3260 application.GetScene().Add(label);
3261 application.SendNotification();
3262 application.Render();
3264 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, 0, 123);
3266 int lineCount = sizeList.Size();
3267 DALI_TEST_EQUALS(4, lineCount, TEST_LOCATION);
3269 application.SendNotification();
3270 application.Render();
3275 int UtcDaliToolkitTextlabelParagraphTag(void)
3277 ToolkitTestApplication application;
3278 tet_infoline(" UtcDaliToolkitTextlabelParagraphTag");
3279 TextLabel labelNewlineSeparator = TextLabel::New();
3280 TextLabel labelParagraphTag = TextLabel::New();
3281 DALI_TEST_CHECK(labelNewlineSeparator);
3282 DALI_TEST_CHECK(labelParagraphTag);
3284 application.GetScene().Add(labelNewlineSeparator);
3285 application.GetScene().Add(labelParagraphTag);
3287 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
3288 labelNewlineSeparator.SetProperty(TextLabel::Property::MULTI_LINE, true);
3289 labelNewlineSeparator.SetProperty(TextLabel::Property::ELLIPSIS, false);
3290 labelNewlineSeparator.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3291 labelNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3292 labelNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3293 labelNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3294 labelNewlineSeparator.SetProperty(TextLabel::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
3296 labelParagraphTag.SetProperty(TextLabel::Property::MULTI_LINE, true);
3297 labelParagraphTag.SetProperty(TextLabel::Property::ELLIPSIS, false);
3298 labelParagraphTag.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3299 labelParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3300 labelParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3301 labelParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3302 labelParagraphTag.SetProperty(TextLabel::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
3304 application.SendNotification();
3305 application.Render();
3307 Vector3 textNaturalSizeNewlineSeparator = labelNewlineSeparator.GetNaturalSize();
3308 Vector3 textNaturalSizeParagraphTag = labelParagraphTag.GetNaturalSize();
3310 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
3312 application.SendNotification();
3313 application.Render();
3318 int utcDaliTextLabelGetTextBoundingRectangle(void)
3320 ToolkitTestApplication application;
3321 tet_infoline(" utcDaliTextLabelGeometryEllipsisMiddle");
3323 TextLabel label = TextLabel::New();
3324 DALI_TEST_CHECK(label);
3326 application.GetScene().Add(label);
3328 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
3329 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3330 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3331 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3332 label.SetProperty(TextLabel::Property::TEXT, "Hello this is the Text Bounding Rectangle TC");
3334 // Avoid a crash when core load gl resources.
3335 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3337 // Render and notify
3338 application.SendNotification();
3339 application.Render();
3341 unsigned int startIndex = 0;
3342 unsigned int endIndex = 15;
3344 Rect<> textBoundingRectangle = DevelTextLabel::GetTextBoundingRectangle(label, startIndex, endIndex);
3345 Rect<> expectedTextBoundingRectangle = {0, 0, 100, 25};
3347 TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);
3352 int utcDaliTextLabelRemoveFrontInset(void)
3354 ToolkitTestApplication application;
3355 tet_infoline(" utcDaliTextLabelRemoveFrontInset");
3357 TextLabel label = TextLabel::New();
3358 DALI_TEST_CHECK(label);
3360 application.GetScene().Add(label);
3361 application.SendNotification();
3362 application.Render();
3364 DevelTextLabel::SetRemoveFrontInset(label, false);
3365 DALI_TEST_CHECK(!DevelTextLabel::IsRemoveFrontInset(label));
3370 int utcDaliTextLabelRemoveBackInset(void)
3372 ToolkitTestApplication application;
3373 tet_infoline(" utcDaliTextLabelRemoveBackInset");
3375 TextLabel label = TextLabel::New();
3376 DALI_TEST_CHECK(label);
3378 application.GetScene().Add(label);
3379 application.SendNotification();
3380 application.Render();
3382 DevelTextLabel::SetRemoveBackInset(label, false);
3383 DALI_TEST_CHECK(!DevelTextLabel::IsRemoveBackInset(label));