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 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
958 outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
959 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
960 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
962 outlineMapSet.Clear();
963 outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
964 outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
965 outlineMapSet[Toolkit::DevelText::Outline::Property::OFFSET] = Vector2(3.0f, 3.0f);
967 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
969 outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
970 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
971 std::vector<std::string> outlineIndicesConversionTable = {"color", "width", "offset"};
972 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet, outlineIndicesConversionTable), true, TEST_LOCATION);
974 // Check the background property
975 Property::Map backgroundMapSet;
976 Property::Map backgroundMapGet;
978 backgroundMapSet["enable"] = true;
979 backgroundMapSet["color"] = Color::RED;
980 label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
982 backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
983 DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
984 DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet), true, TEST_LOCATION);
986 // Check the transparent background property for coverage
987 backgroundMapSet.Clear();
988 backgroundMapSet["enable"] = true;
989 backgroundMapSet["color"] = Color::TRANSPARENT;
990 label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
992 application.SendNotification();
993 application.Render();
995 backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
996 DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
997 DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet), true, TEST_LOCATION);
999 backgroundMapSet.Clear();
1000 backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
1001 backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
1002 label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
1004 backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
1005 DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
1006 std::vector<std::string> backgroundIndicesConversionTable = {"enable", "color"};
1007 DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable), true, TEST_LOCATION);
1009 // Check the pixel size of font
1010 label.SetProperty(TextLabel::Property::PIXEL_SIZE, 20.f);
1011 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1013 // Check the ellipsis property
1014 DALI_TEST_CHECK(label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
1015 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
1016 DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
1018 // Check the layout direction property
1019 label.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1020 DALI_TEST_EQUALS(label.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1022 // Check the line size property
1023 DALI_TEST_EQUALS(label.GetProperty<float>(DevelTextLabel::Property::MIN_LINE_SIZE), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1024 label.SetProperty(DevelTextLabel::Property::MIN_LINE_SIZE, 50.f);
1025 DALI_TEST_EQUALS(label.GetProperty<float>(DevelTextLabel::Property::MIN_LINE_SIZE), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1027 application.SendNotification();
1028 application.Render();
1030 // Check Remove Front/Back Inset Property
1031 DALI_TEST_CHECK(label.GetProperty<bool>(DevelTextLabel::Property::REMOVE_FRONT_INSET));
1032 label.SetProperty(DevelTextLabel::Property::REMOVE_FRONT_INSET, false);
1033 DALI_TEST_CHECK(!label.GetProperty<bool>(DevelTextLabel::Property::REMOVE_FRONT_INSET));
1035 DALI_TEST_CHECK(label.GetProperty<bool>(DevelTextLabel::Property::REMOVE_BACK_INSET));
1036 label.SetProperty(DevelTextLabel::Property::REMOVE_BACK_INSET, false);
1037 DALI_TEST_CHECK(!label.GetProperty<bool>(DevelTextLabel::Property::REMOVE_BACK_INSET));
1039 application.SendNotification();
1040 application.Render();
1045 int UtcDaliToolkitTextlabelAtlasRenderP(void)
1047 ToolkitTestApplication application;
1048 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
1049 TextLabel label = TextLabel::New("Test Text");
1050 DALI_TEST_CHECK(label);
1052 // Avoid a crash when core load gl resources.
1053 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1055 application.GetScene().Add(label);
1057 // Turn on all the effects
1058 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1059 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1061 Property::Map underlineMap;
1062 underlineMap.Insert("enable", true);
1063 underlineMap.Insert("color", Color::RED);
1064 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMap);
1066 Property::Map shadowMap;
1067 shadowMap.Insert("color", Color::BLUE);
1068 shadowMap.Insert("offset", Vector2(1.0f, 1.0f));
1069 label.SetProperty(TextLabel::Property::SHADOW, shadowMap);
1071 Property::Map strikethroughMap;
1072 strikethroughMap.Insert("enable", true);
1073 strikethroughMap.Insert("color", Color::GREEN);
1074 strikethroughMap.Insert("height", 2.0f);
1075 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMap);
1079 // Render some text with the shared atlas backend
1080 label.SetProperty(DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1081 application.SendNotification();
1082 application.Render();
1086 tet_result(TET_FAIL);
1091 // Render some text with the shared atlas backend
1092 label.SetProperty(DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED);
1093 application.SendNotification();
1094 application.Render();
1098 tet_result(TET_FAIL);
1103 int UtcDaliToolkitTextLabelLanguagesP(void)
1105 ToolkitTestApplication application;
1106 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
1107 TextLabel label = TextLabel::New();
1108 DALI_TEST_CHECK(label);
1110 application.GetScene().Add(label);
1112 const std::string scripts(
1113 " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
1114 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
1115 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
1116 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
1117 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
1118 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84."); // these characters on the last line are emojis.
1120 label.SetProperty(TextLabel::Property::TEXT, scripts);
1121 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::TEXT), scripts, TEST_LOCATION);
1123 application.SendNotification();
1124 application.Render();
1129 int UtcDaliToolkitTextLabelEmojisP(void)
1131 ToolkitTestApplication application;
1132 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
1133 TextLabel label = TextLabel::New();
1134 DALI_TEST_CHECK(label);
1136 application.GetScene().Add(label);
1138 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1140 char* pathNamePtr = get_current_dir_name();
1141 const std::string pathName(pathNamePtr);
1144 TextAbstraction::FontDescription fontDescription;
1145 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
1146 fontDescription.family = "BreezeColorEmoji";
1147 fontDescription.width = TextAbstraction::FontWidth::NONE;
1148 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
1149 fontDescription.slant = TextAbstraction::FontSlant::NONE;
1151 fontClient.GetFontId(fontDescription, EMOJI_FONT_SIZE);
1153 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>";
1154 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1155 label.SetProperty(TextLabel::Property::TEXT, emojis);
1157 Property::Map shadowMap;
1158 shadowMap.Insert("color", "green");
1159 shadowMap.Insert("offset", "2 2");
1160 label.SetProperty(TextLabel::Property::SHADOW, shadowMap);
1162 application.SendNotification();
1163 application.Render();
1165 // EMOJI + ZWJ + EMOJI case for coverage.
1166 const std::string emojiWithZWJ = "👩‍🔬";
1167 label.SetProperty(TextLabel::Property::TEXT, emojiWithZWJ);
1169 application.SendNotification();
1170 application.Render();
1172 // EMOJI Sequences case for coverage.
1173 std::string emojiSequences =
1174 "Glyphs not included in the font \n" //case for coverage when glyph is not included in the font
1175 "Text VS15 ☪︎\n" //text presentation sequence and selector
1176 "Color VS16 ☪️\n" //emoji presentation sequence and selector
1177 "Default ☪ \n" //default presentation
1178 "FamilyManWomanGirlBoy 👨‍👩‍👧‍👦\n" // emoji multi zwj sequence
1179 "WomanScientist 👩‍🔬\n" // emoji zwj sequence
1180 "WomanScientistLightSkinTone👩🏻‍🔬 \n" // emoji modifier sequence: skin tone & JWZ
1181 "LeftRightArrowText↔︎\n" // text presentation sequence and selector
1182 "LeftRightArrowEmoji↔️\n" // emoji presentation sequence and selector
1183 "SouthKoreaFlag🇰🇷\n" // emoji flag sequence
1184 "JordanFlag🇯🇴\n" // emoji flag sequence
1185 "EnglandFlag🏴󠁧󠁢󠁥󠁮󠁧󠁿\n" // emoji tag sequence like England flag
1186 "Runner 🏃‍➡️ \n"
1187 "VictoryHandMediumLightSkinTone:✌️🏼\n" // emoji modifier sequence: skin tone
1188 "RainbowFlag:🏳️‍🌈 \n" // emoji zwj sequence: Rainbow Flag
1189 "keycap# #️⃣ \n" // fully-qualified emoji keycap sequence
1190 "keycap#_text #⃣ \n" // unqualified emoji keycap sequence
1191 "keycap3 3️⃣ \n" // fully-qualified emoji keycap sequence
1192 "keycap3_text 3⃣ \n" // unqualified emoji keycap sequence
1193 "two adjacent glyphs ☪️️️☪️\n" // This line should be rendered as two adjacent glyphs
1194 "Digit 8️ 8︎ 8\n" // should be rendered according to selector
1195 "Surfing Medium Skin Female: 🏄🏼‍♀️\n" // Person Surfing + Medium Skin Tone +? Zero Width Joiner + Female Sign
1196 "SYMBOLS_NSLCL variation selector: 🅰️🅱️🅲︎🅳︎🅴︎\n" // 1F170 ~ 1F174 with variation selector, text vs emoji
1197 "SYMBOLS_NSLCL with VS15: 🅰︎🅱︎🅲︎🅳︎🅴︎\n" // 1F170 ~ 1F174 with VS15
1198 "SYMBOLS_NSLCL with VS16: 🅰️🅱️🅲️🅳️🅴️\n" // 1F170 ~ 1F174 with VS16
1202 label.SetProperty(TextLabel::Property::TEXT, emojiSequences);
1203 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1204 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1205 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
1207 application.SendNotification();
1208 application.Render();
1212 int UtcDaliToolkitTextlabelScrollingP(void)
1214 ToolkitTestApplication application;
1215 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
1216 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
1217 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
1219 DALI_TEST_CHECK(labelImmediate);
1220 DALI_TEST_CHECK(labelFinished);
1221 // Avoid a crash when core load gl resources.
1222 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1223 application.GetScene().Add(labelImmediate);
1224 // Turn on all the effects
1225 labelImmediate.SetProperty(TextLabel::Property::MULTI_LINE, false);
1226 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1227 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1228 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1229 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1231 application.GetScene().Add(labelFinished);
1232 // Turn on all the effects
1233 labelFinished.SetProperty(TextLabel::Property::MULTI_LINE, false);
1234 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1235 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1236 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1237 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1241 // Render some text with the shared atlas backend
1242 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1243 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1245 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1246 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1248 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1249 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1250 application.SendNotification();
1251 application.Render();
1253 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1254 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1255 application.SendNotification();
1256 application.Render();
1260 tet_result(TET_FAIL);
1266 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
1268 ToolkitTestApplication application;
1269 TextLabel labelShort = TextLabel::New("Some text to scroll");
1270 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!");
1272 DALI_TEST_CHECK(labelShort);
1273 DALI_TEST_CHECK(labelLong);
1274 // Avoid a crash when core load gl resources.
1275 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1276 application.GetScene().Add(labelShort);
1277 // Turn on all the effects
1278 labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1279 labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1280 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1281 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1282 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1283 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1285 application.GetScene().Add(labelLong);
1286 // Turn on all the effects
1287 labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1288 labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1289 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1290 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1291 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1292 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1296 // Render some text with the shared atlas backend
1297 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1298 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1299 application.SendNotification();
1300 application.Render();
1302 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1303 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1304 application.SendNotification();
1305 application.Render();
1309 tet_result(TET_FAIL);
1315 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
1317 ToolkitTestApplication application;
1318 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1319 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1321 DALI_TEST_CHECK(labelShort);
1322 DALI_TEST_CHECK(labelLong);
1323 // Avoid a crash when core load gl resources.
1324 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1325 application.GetScene().Add(labelShort);
1326 // Turn on all the effects
1327 labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1328 labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1329 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1330 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1331 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1332 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1334 application.GetScene().Add(labelLong);
1335 // Turn on all the effects
1336 labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1337 labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1338 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1339 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1340 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1341 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1345 // Render some text with the shared atlas backend
1346 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1347 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1348 application.SendNotification();
1349 application.Render();
1351 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1352 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1353 application.SendNotification();
1354 application.Render();
1358 tet_result(TET_FAIL);
1364 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
1366 ToolkitTestApplication application;
1367 TextLabel labelShort = TextLabel::New("Some text to scroll");
1368 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!");
1370 DALI_TEST_CHECK(labelShort);
1371 DALI_TEST_CHECK(labelLong);
1372 // Avoid a crash when core load gl resources.
1373 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1374 application.GetScene().Add(labelShort);
1375 // Turn on all the effects
1376 labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1377 labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1378 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1379 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1380 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1381 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1383 application.GetScene().Add(labelLong);
1384 // Turn on all the effects
1385 labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1386 labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1387 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1388 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1389 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1390 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1394 // Render some text with the shared atlas backend
1395 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1396 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1397 application.SendNotification();
1398 application.Render();
1400 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1401 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1402 application.SendNotification();
1403 application.Render();
1407 tet_result(TET_FAIL);
1413 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
1415 ToolkitTestApplication application;
1416 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1417 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1419 DALI_TEST_CHECK(labelShort);
1420 DALI_TEST_CHECK(labelLong);
1421 // Avoid a crash when core load gl resources.
1422 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1423 application.GetScene().Add(labelShort);
1424 // Turn on all the effects
1425 labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1426 labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1427 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1428 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1429 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1430 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1432 application.GetScene().Add(labelLong);
1433 // Turn on all the effects
1434 labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1435 labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1436 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1437 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1438 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1439 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1443 // Render some text with the shared atlas backend
1444 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1445 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1446 application.SendNotification();
1447 application.Render();
1449 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1450 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1451 application.SendNotification();
1452 application.Render();
1456 tet_result(TET_FAIL);
1462 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1464 ToolkitTestApplication application;
1465 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1466 TextLabel label = TextLabel::New("Some text to scroll");
1467 DALI_TEST_CHECK(label);
1468 // Avoid a crash when core load gl resources.
1469 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1470 application.GetScene().Add(label);
1471 label.SetProperty(Actor::Property::SIZE, Vector2(360.0f, 20.f));
1472 // Turn on all the effects
1473 label.SetProperty(TextLabel::Property::MULTI_LINE, false);
1474 label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1475 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1476 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1479 application.SendNotification();
1480 application.Render();
1482 unsigned int actorCount1 = label.GetChildCount();
1483 tet_printf("Initial actor count is(%d)\n", actorCount1);
1487 // Render some text with the shared atlas backend
1488 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1489 application.SendNotification();
1490 application.Render(2000);
1492 unsigned int actorCount1 = label.GetChildCount();
1493 tet_printf("Actor count after scrolling is(%d)\n", actorCount1);
1495 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1498 application.SendNotification();
1499 application.Render();
1501 unsigned int actorCount2 = label.GetChildCount();
1502 tet_printf("After changing color the actor count is(%d)\n", actorCount2);
1504 DALI_TEST_EQUALS(actorCount1, actorCount2, TEST_LOCATION);
1508 tet_result(TET_FAIL);
1514 int UtcDaliToolkitTextlabelScrollingN(void)
1516 ToolkitTestApplication application;
1517 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1519 TextLabel label = TextLabel::New("Some text to scroll");
1520 DALI_TEST_CHECK(label);
1522 application.GetScene().Add(label);
1524 // Avoid a crash when core load gl resources.
1525 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1527 // The text scrolling works only on single line text.
1528 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1530 // Turn on all the effects.
1531 label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1532 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1533 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1535 // Enable the auto scrolling effect.
1536 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1538 // The auto scrolling shouldn't be enabled.
1539 const bool enabled = label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>();
1540 DALI_TEST_CHECK(!enabled);
1542 label.SetProperty(TextLabel::Property::MULTI_LINE, false);
1543 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 1);
1544 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 9999.0f);
1545 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1550 application.SendNotification();
1551 application.Render(1000);
1553 application.GetScene().Remove(label);
1554 application.SendNotification();
1555 application.Render();
1557 DALI_TEST_CHECK(!label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
1559 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1560 application.GetScene().Add(label);
1562 application.SendNotification();
1563 application.Render();
1565 DALI_TEST_CHECK(label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
1567 label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, (Toolkit::TextLabel::AutoScrollStopMode::Type)2); // invalid type
1568 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1570 application.SendNotification();
1571 application.Render();
1573 DALI_TEST_CHECK(label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
1577 tet_result(TET_FAIL);
1583 int UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
1585 ToolkitTestApplication application;
1586 tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
1588 TextLabel label = TextLabel::New("Some text to scroll");
1589 DALI_TEST_CHECK(label);
1591 application.GetScene().Add(label);
1593 // Avoid a crash when core load gl resources.
1594 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1596 // Turn on all the effects.
1597 label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1598 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1599 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1603 // Enable the auto scrolling effect.
1604 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1605 label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1607 // Disable the ellipsis
1608 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
1611 application.SendNotification();
1612 application.Render();
1614 // Stop auto scrolling
1615 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1617 // Check the ellipsis property
1618 DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
1622 tet_result(TET_FAIL);
1628 int UtcDaliToolkitTextlabelEllipsis(void)
1630 ToolkitTestApplication application;
1631 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1633 TextLabel label = TextLabel::New("Hello world");
1634 DALI_TEST_CHECK(label);
1636 // Avoid a crash when core load gl resources.
1637 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1639 application.GetScene().Add(label);
1641 // Turn on all the effects
1642 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1643 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1644 label.SetProperty(Actor::Property::SIZE, Vector2(360.0f, 10.f));
1649 application.SendNotification();
1650 application.Render();
1654 tet_result(TET_FAIL);
1657 label.SetProperty(TextLabel::Property::TEXT, "Hello world ");
1658 label.SetProperty(DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false);
1659 label.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 10.f));
1664 application.SendNotification();
1665 application.Render();
1669 tet_result(TET_FAIL);
1672 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1673 label.SetProperty(DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
1674 label.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 10.f));
1679 application.SendNotification();
1680 application.Render();
1684 tet_result(TET_FAIL);
1690 int UtcDaliToolkitTextlabelTextWrapMode(void)
1692 ToolkitTestApplication application;
1693 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1697 TextLabel label = TextLabel::New();
1698 label.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.f));
1699 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1700 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1702 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1703 application.GetScene().Add(label);
1705 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "WORD");
1706 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
1708 application.SendNotification();
1709 application.Render();
1711 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1712 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1714 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
1715 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1717 application.SendNotification();
1718 application.Render();
1720 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD);
1721 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
1723 application.SendNotification();
1724 application.Render();
1726 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1727 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1729 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER);
1730 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1732 application.SendNotification();
1733 application.Render();
1735 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1736 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1738 tet_infoline("Ensure invalid string does not change wrapping mode");
1739 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode");
1740 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1745 int UtcDaliToolkitTextLabelColorComponents(void)
1747 ToolkitTestApplication application;
1749 TextLabel label = TextLabel::New();
1750 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1751 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 1.0f, TEST_LOCATION);
1752 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 0.0f, TEST_LOCATION);
1753 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 0.0f, TEST_LOCATION);
1754 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1756 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::GREEN);
1757 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 0.0f, TEST_LOCATION);
1758 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 1.0f, TEST_LOCATION);
1759 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 0.0f, TEST_LOCATION);
1760 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1762 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLUE);
1763 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 0.0f, TEST_LOCATION);
1764 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 0.0f, TEST_LOCATION);
1765 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 1.0f, TEST_LOCATION);
1766 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1768 label.SetProperty(TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f);
1769 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 0.6f, TEST_LOCATION);
1770 DALI_TEST_EQUALS(label.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR), Vector4(0.0f, 0.0f, 1.0f, 0.6f), TEST_LOCATION);
1772 // Test a transparent text - Rendering should be skipped.
1773 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1774 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLUE);
1776 application.GetScene().Add(label);
1778 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1779 drawTrace.Enable(true);
1781 application.SendNotification();
1782 application.Render();
1784 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION); // Should be rendered
1786 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT);
1790 application.SendNotification();
1791 application.Render();
1793 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), false, TEST_LOCATION); // Rendering should be skipped
1795 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1799 application.SendNotification();
1800 application.Render();
1802 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION); // Should be rendered again
1807 int UtcDaliToolkitTextlabelTextStyle01(void)
1809 ToolkitTestApplication application;
1810 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1812 TextLabel label = TextLabel::New();
1813 label.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.f));
1814 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1815 label.SetProperty(TextLabel::Property::POINT_SIZE, 12);
1816 application.GetScene().Add(label);
1818 Property::Map outlineMapSet;
1819 Property::Map outlineMapGet;
1821 outlineMapSet["color"] = Color::BLUE;
1822 outlineMapSet["width"] = 2.0f;
1823 outlineMapSet["offset"] = "2 2";
1824 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
1826 application.SendNotification();
1827 application.Render();
1829 Property::Map shadowMapSet;
1830 shadowMapSet.Insert("color", "green");
1831 shadowMapSet.Insert("offset", "2 2");
1832 shadowMapSet.Insert("blurRadius", "3");
1833 label.SetProperty(TextLabel::Property::SHADOW, shadowMapSet);
1835 outlineMapSet["color"] = Color::RED;
1836 outlineMapSet["width"] = 0.0f;
1837 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
1839 application.SendNotification();
1840 application.Render();
1842 outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
1844 Property::Value* colorValue = outlineMapGet.Find("color");
1846 bool colorMatched(false);
1850 Property::Type valueType = colorValue->GetType();
1852 if(Property::STRING == valueType)
1854 std::string stringValue;
1855 colorValue->Get(stringValue);
1856 if(stringValue == "red")
1858 colorMatched = true;
1861 else if(Property::VECTOR4 == valueType)
1863 Vector4 colorVector4;
1864 colorValue->Get(colorVector4);
1865 if(colorVector4 == Color::RED)
1867 colorMatched = true;
1872 DALI_TEST_EQUALS(colorMatched, true, TEST_LOCATION);
1877 int UtcDaliToolkitTextlabelMultiline(void)
1879 ToolkitTestApplication application;
1880 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1882 TextLabel label = TextLabel::New();
1883 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world");
1884 label.SetProperty(TextLabel::Property::POINT_SIZE, 20);
1885 label.SetProperty(TextLabel::Property::MULTI_LINE, false);
1886 application.GetScene().Add(label);
1888 application.SendNotification();
1889 application.Render();
1891 int lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1892 DALI_TEST_EQUALS(lineCount, 1, TEST_LOCATION);
1894 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1896 application.SendNotification();
1897 application.Render();
1899 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1900 DALI_TEST_EQUALS(true, (lineCount > 1), TEST_LOCATION);
1905 int UtcDaliToolkitTextlabelTextDirection(void)
1907 ToolkitTestApplication application;
1908 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1910 TextLabel label = TextLabel::New();
1911 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT), TEST_LOCATION);
1913 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1914 label.SetProperty(TextLabel::Property::POINT_SIZE, 20);
1915 label.SetProperty(DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
1916 application.GetScene().Add(label);
1919 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT), TEST_LOCATION);
1922 label.SetProperty(TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ");
1923 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1925 // Test RTL text starting with weak character
1926 label.SetProperty(TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ");
1927 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1929 // Test RTL text string with emoji and weak character
1930 label.SetProperty(TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ");
1931 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1936 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1938 ToolkitTestApplication application;
1939 tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1941 TextLabel label = TextLabel::New();
1943 label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP);
1944 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1945 label.SetProperty(TextLabel::Property::POINT_SIZE, 15);
1946 label.SetProperty(TextLabel::Property::LINE_SPACING, 12);
1947 application.GetScene().Add(label);
1948 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::TOP), TEST_LOCATION);
1950 label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE);
1951 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::MIDDLE), TEST_LOCATION);
1953 label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM);
1954 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::BOTTOM), TEST_LOCATION);
1959 int UtcDaliToolkitTextLabelBitmapFont(void)
1961 ToolkitTestApplication application;
1962 tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1964 DevelText::BitmapFontDescription fontDescription;
1965 fontDescription.name = "Digits";
1966 fontDescription.underlinePosition = 0.f;
1967 fontDescription.underlineThickness = 0.f;
1969 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f});
1970 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f});
1971 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f});
1972 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f});
1973 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f});
1974 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f});
1975 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f});
1976 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f});
1977 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f});
1978 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f});
1979 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f});
1981 TextAbstraction::BitmapFont bitmapFont;
1982 DevelText::CreateBitmapFont(fontDescription, bitmapFont);
1984 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1985 fontClient.GetFontId(bitmapFont);
1987 TextLabel label = TextLabel::New();
1989 label.SetProperty(TextLabel::Property::TEXT, "0123456789:");
1990 label.SetProperty(TextLabel::Property::FONT_FAMILY, "Digits");
1992 // 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.
1993 DALI_TEST_EQUALS(label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1995 application.GetScene().Add(label);
1997 application.SendNotification();
1998 application.Render();
2000 // The text has been rendered if the height of the text-label is the height of the line.
2001 DALI_TEST_EQUALS(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2006 int ConvertPointToPixel(float point)
2008 unsigned int horizontalDpi = 0u;
2009 unsigned int verticalDpi = 0u;
2010 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2011 fontClient.GetDpi(horizontalDpi, verticalDpi);
2013 return (point * 72.f) / static_cast<float>(horizontalDpi);
2016 int UtcDaliToolkitTextlabelTextFit(void)
2018 ToolkitTestApplication application;
2019 tet_infoline(" UtcDaliToolkitTextlabelTextFit");
2020 TextLabel label = TextLabel::New();
2021 Vector2 size(460.0f, 100.0f);
2022 label.SetProperty(Actor::Property::SIZE, size);
2023 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
2025 // connect to the text git changed signal.
2026 ConnectionTracker* testTracker = new ConnectionTracker();
2027 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2028 bool textFitChangedSignal = false;
2029 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2030 gTextFitChangedCallBackCalled = false;
2033 Property::Map textFitMapSet;
2034 textFitMapSet["enable"] = true;
2035 textFitMapSet["minSize"] = 10.f;
2036 textFitMapSet["maxSize"] = 100.f;
2037 textFitMapSet["stepSize"] = -1.f;
2038 textFitMapSet["fontSizeType"] = "pointSize";
2040 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2041 label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2043 application.GetScene().Add(label);
2045 application.SendNotification();
2046 application.Render();
2048 const Vector3 EXPECTED_NATURAL_SIZE(448.0f, 96.0f, 0.0f);
2049 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2051 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2052 DALI_TEST_CHECK(textFitChangedSignal);
2055 textFitMapSet.Clear();
2056 textFitMapSet["enable"] = true;
2057 textFitMapSet["minSize"] = ConvertPointToPixel(10.f);
2058 textFitMapSet["maxSize"] = ConvertPointToPixel(100.f);
2059 textFitMapSet["stepSize"] = ConvertPointToPixel(1.f);
2060 textFitMapSet["fontSizeType"] = "pixelSize";
2062 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2064 application.SendNotification();
2065 application.Render();
2067 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2072 int UtcDaliToolkitTextlabelTextFitStressTest(void)
2074 ToolkitTestApplication application;
2075 tet_infoline(" UtcDaliToolkitTextlabelTextFitStressTest");
2076 TextLabel label = TextLabel::New();
2077 Vector2 size(460.0f, 100.0f);
2078 label.SetProperty(Actor::Property::SIZE, size);
2079 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
2081 // connect to the text git changed signal.
2082 ConnectionTracker* testTracker = new ConnectionTracker();
2083 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2084 bool textFitChangedSignal = false;
2085 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2086 gTextFitChangedCallBackCalled = false;
2088 // check point size with veryvery big range
2089 Property::Map textFitMapSet;
2090 textFitMapSet["enable"] = true;
2091 textFitMapSet["minSize"] = 10.f;
2092 textFitMapSet["maxSize"] = 10000.f;
2093 textFitMapSet["stepSize"] = -1.0f;
2094 textFitMapSet["fontSizeType"] = "pointSize";
2096 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2097 label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2099 application.GetScene().Add(label);
2101 application.SendNotification();
2102 application.Render();
2104 const Vector3 EXPECTED_NATURAL_SIZE(448.0f, 96.0f, 0.0f);
2105 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2107 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2108 DALI_TEST_CHECK(textFitChangedSignal);
2113 int UtcDaliToolkitTextlabelFastTextFitStressTest(void)
2115 ToolkitTestApplication application;
2116 tet_infoline(" UtcDaliToolkitTextlabelFastTextFitStressTest");
2117 TextLabel label = TextLabel::New();
2118 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
2119 label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2121 // connect to the text git changed signal.
2122 ConnectionTracker* testTracker = new ConnectionTracker();
2123 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2124 bool textFitChangedSignal = false;
2125 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2126 gTextFitChangedCallBackCalled = false;
2128 application.GetScene().Add(label);
2130 // check text label width at range [100, 299]
2131 for(int i=100; i<300; i++)
2133 Vector2 size((float)i, 200.f);
2134 label.SetProperty(Actor::Property::SIZE, size);
2136 // check point size with veryvery big range
2137 Property::Map textFitMapSet;
2138 textFitMapSet["enable"] = true;
2139 textFitMapSet["minSize"] = 10.f;
2140 textFitMapSet["maxSize"] = 10000.f;
2141 textFitMapSet["stepSize"] = -1.0f;
2142 textFitMapSet["fontSizeType"] = "pointSize";
2144 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2146 application.SendNotification();
2147 application.Render();
2150 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2151 DALI_TEST_CHECK(textFitChangedSignal);
2156 int UtcDaliToolkitTextlabelTextFitMultiLine(void)
2158 ToolkitTestApplication application;
2159 tet_infoline(" UtcDaliToolkitTextlabelTextFitMultiLine");
2160 TextLabel label = TextLabel::New();
2161 Vector2 size(500.0f, 100.0f);
2162 label.SetProperty(Actor::Property::SIZE, size);
2163 label.SetProperty(TextLabel::Property::TEXT, "Hello world\nHello world");
2164 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2166 // connect to the text git changed signal.
2167 ConnectionTracker* testTracker = new ConnectionTracker();
2168 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2169 bool textFitChangedSignal = false;
2170 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2171 gTextFitChangedCallBackCalled = false;
2173 Property::Map textFitMapSet;
2174 textFitMapSet["enable"] = true;
2175 textFitMapSet["minSize"] = 10.f;
2176 textFitMapSet["maxSize"] = 100.f;
2177 textFitMapSet["stepSize"] = -1.0f;
2178 textFitMapSet["fontSizeType"] = "pointSize";
2180 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2181 label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2183 application.GetScene().Add(label);
2185 application.SendNotification();
2186 application.Render();
2188 float textFitFontSize = (label.GetProperty(Dali::Toolkit::DevelTextLabel::Property::TEXT_FIT).Get<Property::Map>())["fontSize"].Get<float>();
2189 DALI_TEST_EQUALS(textFitFontSize, 14.f, TEST_LOCATION);
2191 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2192 DALI_TEST_CHECK(textFitChangedSignal);
2197 int UtcDaliToolkitTextlabelTextFitArray(void)
2199 ToolkitTestApplication application;
2200 tet_infoline(" UtcDaliToolkitTextlabelTextFitArray");
2201 TextLabel label = TextLabel::New();
2202 Vector2 size(300.0f, 80.0f);
2203 label.SetProperty(Actor::Property::SIZE, size);
2204 label.SetProperty(TextLabel::Property::TEXT, "A Quick Brown Fox Jumps Over The Lazy Dog");
2205 label.SetProperty(DevelTextLabel::Property::MIN_LINE_SIZE, 80.f);
2206 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
2207 application.GetScene().Add(label);
2209 // make sorted options.
2210 std::vector<DevelTextLabel::FitOption> fitOptions;
2211 fitOptions.push_back(DevelTextLabel::FitOption(10, 12));
2212 fitOptions.push_back(DevelTextLabel::FitOption(8, 10));
2213 fitOptions.push_back(DevelTextLabel::FitOption(6, 8));
2214 fitOptions.push_back(DevelTextLabel::FitOption(4, 6));
2215 fitOptions.push_back(DevelTextLabel::FitOption(20, 22));
2216 fitOptions.push_back(DevelTextLabel::FitOption(22, 24));
2217 fitOptions.push_back(DevelTextLabel::FitOption(12, 14));
2219 DevelTextLabel::SetTextFitArray(label, true, fitOptions);
2221 application.SendNotification();
2222 application.Render();
2224 bool enable = Dali::Toolkit::DevelTextLabel::IsTextFitArrayEnabled(label);
2225 DALI_TEST_EQUALS(true, enable, TEST_LOCATION);
2227 std::vector<Dali::Toolkit::DevelTextLabel::FitOption> getFitOptions = Dali::Toolkit::DevelTextLabel::GetTextFitArray(label);
2228 size_t numberOfFitOptions = getFitOptions.size();
2229 DALI_TEST_EQUALS(7u, numberOfFitOptions, TEST_LOCATION);
2231 const Vector3 EXPECTED_NATURAL_SIZE(276.0f, 16.0f, 0.0f);
2232 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2234 std::vector<DevelTextLabel::FitOption> emptyFitOptions;
2235 DevelTextLabel::SetTextFitArray(label, false, emptyFitOptions);
2237 application.SendNotification();
2238 application.Render();
2240 enable = Dali::Toolkit::DevelTextLabel::IsTextFitArrayEnabled(label);
2241 DALI_TEST_EQUALS(false, enable, TEST_LOCATION);
2243 const Vector3 EXPECTED_NATURAL_SIZE_DISABLE(690.0f, 80.0f, 0.0f);
2244 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE_DISABLE, label.GetNaturalSize(), TEST_LOCATION);
2246 // make unsorted options.
2247 std::vector<DevelTextLabel::FitOption> unorderedFitOptions;
2248 unorderedFitOptions.push_back(DevelTextLabel::FitOption(4, 6));
2249 unorderedFitOptions.push_back(DevelTextLabel::FitOption(6, 8));
2250 unorderedFitOptions.push_back(DevelTextLabel::FitOption(8, 10));
2251 unorderedFitOptions.push_back(DevelTextLabel::FitOption(10, 8));
2253 DevelTextLabel::SetTextFitArray(label, true, unorderedFitOptions);
2255 application.SendNotification();
2256 application.Render();
2258 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2263 int UtcDaliToolkitTextlabelMaxTextureSet(void)
2265 ToolkitTestApplication application;
2266 tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
2268 DevelText::BitmapFontDescription fontDescription;
2269 fontDescription.name = "Digits";
2270 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f});
2272 TextAbstraction::BitmapFont bitmapFont;
2273 DevelText::CreateBitmapFont(fontDescription, bitmapFont);
2275 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2276 fontClient.GetFontId(bitmapFont);
2278 TextLabel label = TextLabel::New();
2279 label.SetProperty(TextLabel::Property::FONT_FAMILY, "Digits");
2280 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2281 label.SetProperty(TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded.");
2282 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2283 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2285 Property::Map underlineMapSet;
2286 underlineMapSet.Clear();
2287 underlineMapSet.Insert("enable", true);
2288 underlineMapSet.Insert("color", Color::RED);
2289 underlineMapSet.Insert("height", 1);
2290 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2291 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2293 Property::Map strikethroughMapSet;
2294 strikethroughMapSet.Clear();
2295 strikethroughMapSet.Insert("enable", true);
2296 strikethroughMapSet.Insert("color", Color::RED);
2297 strikethroughMapSet.Insert("height", 2.0f);
2298 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2299 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2301 application.GetScene().Add(label);
2303 application.SendNotification();
2304 application.Render();
2306 const int maxTextureSize = Dali::GetMaxTextureSize();
2307 // Whether the rendered text is greater than maxTextureSize
2308 DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2310 // Check if the number of renderers is greater than 1.
2311 DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2314 underlineMapSet.Clear();
2315 underlineMapSet.Insert("enable", false);
2316 underlineMapSet.Insert("color", Color::BLUE);
2317 underlineMapSet.Insert("height", 0);
2318 underlineMapSet.Insert("type", Text::Underline::DASHED);
2319 underlineMapSet.Insert("dashWidth", 2);
2320 underlineMapSet.Insert("dashGap", 1);
2321 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2322 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2324 application.GetScene().Add(label);
2326 application.SendNotification();
2327 application.Render();
2329 // Whether the rendered text is greater than maxTextureSize
2330 DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2332 // Check if the number of renderers is greater than 1.
2333 DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2336 underlineMapSet.Clear();
2337 underlineMapSet.Insert("enable", false);
2338 underlineMapSet.Insert("color", Color::BLUE);
2339 underlineMapSet.Insert("height", 0);
2340 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
2341 underlineMapSet.Insert("dashWidth", 2);
2342 underlineMapSet.Insert("dashGap", 1);
2343 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2344 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2346 application.GetScene().Add(label);
2348 application.SendNotification();
2349 application.Render();
2351 // Whether the rendered text is greater than maxTextureSize
2352 DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2354 // Check if the number of renderers is greater than 1.
2355 DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2357 // Coverage test for case of layoutSize is bigger than maxTextureSize
2358 float max_value = static_cast<float>(std::numeric_limits<uint16_t>::max());
2359 label.SetProperty(Actor::Property::SIZE, Vector2(max_value, 30.0f));
2360 application.SendNotification();
2361 application.Render();
2366 int UtcDaliToolkitTextlabelStrikethroughExceedsWidthAndHeight(void)
2368 ToolkitTestApplication application;
2369 tet_infoline(" UtcDaliToolkitTextlabelStrikethroughExceedsWidthAndHeight");
2371 TextLabel label = TextLabel::New();
2372 label.SetProperty(TextLabel::Property::TEXT, "Test");
2373 label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2374 //Exeeding BufferWidth
2375 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 400.0f));
2376 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2377 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2379 application.GetScene().Add(label);
2380 application.SendNotification();
2381 application.Render();
2383 Property::Map strikethroughMapSet;
2384 strikethroughMapSet.Clear();
2385 strikethroughMapSet.Insert("enable", true);
2386 strikethroughMapSet.Insert("color", Color::BLUE);
2387 strikethroughMapSet.Insert("height", 2.0f);
2388 label.SetProperty(TextLabel::Property::TEXT, "Test1");
2389 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2390 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2391 application.GetScene().Add(label);
2392 application.SendNotification();
2393 application.Render();
2394 // Check if the number of renderers is 1.
2395 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2397 label = TextLabel::New();
2398 label.SetProperty(TextLabel::Property::TEXT, "Test");
2399 label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2401 //Exeeding BufferHeight
2402 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.0f));
2403 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2404 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2406 application.GetScene().Add(label);
2407 application.SendNotification();
2408 application.Render();
2410 strikethroughMapSet.Clear();
2411 strikethroughMapSet.Insert("enable", true);
2412 strikethroughMapSet.Insert("color", Color::BLUE);
2413 strikethroughMapSet.Insert("height", 2.0f);
2414 label.SetProperty(TextLabel::Property::TEXT, "Test2");
2415 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2416 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2417 application.GetScene().Add(label);
2418 application.SendNotification();
2419 application.Render();
2420 // Check if the number of renderers is 1.
2421 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2426 int UtcDaliToolkitTextlabelUnderlineExceedsWidth(void)
2428 ToolkitTestApplication application;
2429 tet_infoline(" UtcDaliToolkitTextlabelUnderlineExceedsWidth");
2431 TextLabel label = TextLabel::New();
2432 label.SetProperty(TextLabel::Property::TEXT, "Test");
2433 label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2434 //Exeeding BufferWidth
2435 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 400.0f));
2436 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2437 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2439 application.GetScene().Add(label);
2440 application.SendNotification();
2441 application.Render();
2443 Property::Map underlineMapSet;
2446 underlineMapSet.Clear();
2447 underlineMapSet.Insert("enable", true);
2448 underlineMapSet.Insert("color", Color::BLUE);
2449 underlineMapSet.Insert("height", 1);
2450 underlineMapSet.Insert("type", Text::Underline::SOLID);
2451 underlineMapSet.Insert("dashWidth", 2);
2452 underlineMapSet.Insert("dashGap", 1);
2453 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2454 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2456 application.GetScene().Add(label);
2458 application.SendNotification();
2459 application.Render();
2461 // Check if the number of renderers is 1.
2462 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2465 underlineMapSet.Clear();
2466 underlineMapSet.Insert("enable", true);
2467 underlineMapSet.Insert("color", Color::BLUE);
2468 underlineMapSet.Insert("height", 1);
2469 underlineMapSet.Insert("type", Text::Underline::DASHED);
2470 underlineMapSet.Insert("dashWidth", 2);
2471 underlineMapSet.Insert("dashGap", 1);
2472 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2473 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2475 application.GetScene().Add(label);
2477 application.SendNotification();
2478 application.Render();
2480 // Check if the number of renderers is 1.
2481 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2484 underlineMapSet.Clear();
2485 underlineMapSet.Insert("enable", true);
2486 underlineMapSet.Insert("color", Color::BLUE);
2487 underlineMapSet.Insert("height", 1);
2488 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
2489 underlineMapSet.Insert("dashWidth", 2);
2490 underlineMapSet.Insert("dashGap", 1);
2491 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2492 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2494 application.GetScene().Add(label);
2496 application.SendNotification();
2497 application.Render();
2499 // Check if the number of renderers is 1.
2500 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2505 int UtcDaliToolkitTextlabelLastCharacterIndex(void)
2507 ToolkitTestApplication application;
2508 tet_infoline(" UtcDaliToolkitTextlabelLastCharacterIndex");
2510 Vector2 size(300.0f, 100.0f);
2512 Dali::Toolkit::DevelText::RendererParameters textParameters;
2513 textParameters.text = "This is a sample text to get the last index.";
2514 textParameters.layout = "multiLine";
2515 textParameters.fontSize = 20.f;
2516 textParameters.textWidth = 300u;
2517 textParameters.textHeight = 100u;
2518 textParameters.ellipsisEnabled = true;
2519 Dali::Property::Array indexArray = Dali::Toolkit::DevelText::GetLastCharacterIndex(textParameters);
2521 DALI_TEST_CHECK(!indexArray.Empty());
2522 DALI_TEST_EQUALS(indexArray.GetElementAt(0).Get<int>(), 10, TEST_LOCATION);
2527 int UtcDaliToolkitTextlabelFontSizeScale(void)
2529 ToolkitTestApplication application;
2530 tet_infoline(" UtcDaliToolkitTextlabelFontSizeScale");
2532 TextLabel label = TextLabel::New();
2533 label.SetProperty(TextLabel::Property::POINT_SIZE, 30.f);
2534 label.SetProperty(TextLabel::Property::TEXT, "Test");
2535 Vector3 nonScaledSize = label.GetNaturalSize();
2537 TextLabel labelScaled = TextLabel::New();
2538 labelScaled.SetProperty(TextLabel::Property::POINT_SIZE, 15.f);
2539 labelScaled.SetProperty(Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f);
2540 labelScaled.SetProperty(TextLabel::Property::TEXT, "Test");
2541 Vector3 scaledSize = labelScaled.GetNaturalSize();
2543 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
2545 label.SetProperty(TextLabel::Property::PIXEL_SIZE, 30.f);
2546 label.SetProperty(TextLabel::Property::TEXT, "Test");
2547 nonScaledSize = label.GetNaturalSize();
2549 labelScaled.SetProperty(TextLabel::Property::PIXEL_SIZE, 15.f);
2550 labelScaled.SetProperty(Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f);
2551 labelScaled.SetProperty(TextLabel::Property::TEXT, "Test");
2552 scaledSize = labelScaled.GetNaturalSize();
2554 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
2559 int UtcDaliToolkitTextlabelAnchorColor(void)
2561 ToolkitTestApplication application;
2562 tet_infoline(" UtcDaliToolkitTextlabelAnchorColor");
2563 TextLabel label = TextLabel::New();
2564 DALI_TEST_CHECK(label);
2566 application.GetScene().Add(label);
2568 // connect to the anchor clicked signal.
2569 ConnectionTracker* testTracker = new ConnectionTracker();
2570 DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
2571 bool anchorClickedSignal = false;
2572 label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
2574 gAnchorClickedCallBackCalled = false;
2575 label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
2576 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2577 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2578 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2579 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2581 // Check that anchor color can be properly set
2582 label.SetProperty(DevelTextLabel::Property::ANCHOR_COLOR, Color::BLUE);
2583 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_COLOR), Color::BLUE, TEST_LOCATION);
2585 label.SetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR, Color::RED);
2586 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR), Color::RED, TEST_LOCATION);
2588 application.SendNotification();
2589 application.Render();
2591 // Create a tap event to touch the text label.
2592 TestGenerateTap(application, 5.0f, 25.0f, 100);
2593 application.SendNotification();
2594 application.Render();
2596 // Update clicked color
2597 label.SetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR, Color::BLUE);
2598 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR), Color::BLUE, TEST_LOCATION);
2600 application.SendNotification();
2601 application.Render();
2603 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2604 DALI_TEST_CHECK(anchorClickedSignal);
2609 // Positive test for the anchorClicked signal.
2610 int UtcDaliToolkitTextlabelAnchorClicked(void)
2612 ToolkitTestApplication application;
2613 tet_infoline(" UtcDaliToolkitTextlabelAnchorClicked");
2614 TextLabel label = TextLabel::New();
2615 DALI_TEST_CHECK(label);
2617 application.GetScene().Add(label);
2619 // connect to the anchor clicked signal.
2620 ConnectionTracker* testTracker = new ConnectionTracker();
2621 DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
2622 bool anchorClickedSignal = false;
2623 label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
2625 gAnchorClickedCallBackCalled = false;
2626 label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
2627 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2628 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2629 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2630 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2632 application.SendNotification();
2633 application.Render();
2635 // Create a tap event to touch the text label.
2636 TestGenerateTap(application, 5.0f, 25.0f, 100);
2637 application.SendNotification();
2638 application.Render();
2640 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2641 DALI_TEST_CHECK(anchorClickedSignal);
2644 gAnchorClickedCallBackCalled = false;
2645 anchorClickedSignal = false;
2646 label.SetProperty(TextLabel::Property::TEXT, "");
2647 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, false);
2649 application.SendNotification();
2650 application.Render();
2653 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2654 label.SetProperty(TextLabel::Property::TEXT, "<a color='red' clicked-color='green' href='https://www.tizen.org'>TIZEN</a>");
2655 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2656 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2657 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2659 application.SendNotification();
2660 application.Render();
2662 // Create a tap event to touch the text label.
2663 TestGenerateTap(application, 5.0f, 25.0f, 200);
2664 application.SendNotification();
2665 application.Render();
2667 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2668 DALI_TEST_CHECK(anchorClickedSignal);
2670 gAnchorClickedCallBackNotCalled = true;
2671 // Tap the outside of anchor, callback should not be called.
2672 TestGenerateTap(application, 150.f, 100.f, 300);
2673 application.SendNotification();
2674 application.Render();
2676 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
2681 int UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize(void)
2683 ToolkitTestApplication application;
2684 tet_infoline(" UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize ");
2686 //TextLabel is not using Atlas but this is to unify font-size on text-controllers
2688 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
2689 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
2690 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
2692 // Create a text editor
2693 TextLabel textLabel = TextLabel::New();
2694 //Set size to avoid automatic eliding
2695 textLabel.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
2696 //Set very large font-size using point-size
2697 textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 1000);
2698 //Specify font-family
2699 textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2700 //Set text to check if appear or not
2701 textLabel.SetProperty(TextLabel::Property::TEXT, "A");
2703 application.GetScene().Add(textLabel);
2705 application.SendNotification();
2706 application.Render();
2707 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
2708 Vector3 naturalSize = textLabel.GetNaturalSize();
2710 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
2711 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
2716 int UtcDaliTextLabelHyphenWrapMode(void)
2718 ToolkitTestApplication application;
2719 tet_infoline(" UtcDaliTextLabelHyphenWrapMode ");
2722 TextLabel label = TextLabel::New();
2723 label.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
2724 label.SetProperty(TextLabel::Property::POINT_SIZE, 12.f);
2725 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2726 application.GetScene().Add(label);
2727 application.SendNotification();
2728 application.Render();
2730 label.SetProperty(TextLabel::Property::TEXT, "Hi Experimen");
2731 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
2732 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::HYPHENATION), TEST_LOCATION);
2734 application.SendNotification();
2735 application.Render();
2737 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2743 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
2745 label.SetProperty(TextLabel::Property::TEXT, "Hi Experimen");
2746 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
2747 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::MIXED), TEST_LOCATION);
2749 application.SendNotification();
2750 application.Render();
2752 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2759 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
2764 int utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged(void)
2766 ToolkitTestApplication application;
2768 tet_infoline(" utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged ");
2770 int lineCountBefore = 0;
2771 int lineCountAfter = 0;
2773 // Create a text editor
2774 TextLabel textLabel = TextLabel::New();
2775 //Set very large font-size using point-size
2776 textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 10);
2777 //Specify font-family
2778 textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2780 textLabel.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.f));
2781 //Set text longer than width of textLabel
2782 textLabel.SetProperty(TextLabel::Property::TEXT, "Short text");
2783 //Set line wrap mode Character
2784 textLabel.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
2785 textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
2787 application.GetScene().Add(textLabel);
2789 application.SendNotification();
2790 application.Render();
2792 lineCountBefore = textLabel.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2794 textLabel.SetProperty(TextLabel::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
2795 lineCountAfter = textLabel.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2797 // When the text changed, the Line-count should be updated according to new text.
2798 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
2799 DALI_TEST_EQUALS(lineCountBefore, 1, TEST_LOCATION);
2800 DALI_TEST_GREATER(lineCountAfter, 1, TEST_LOCATION);
2805 int utcDaliTextLabelGeometryRTL(void)
2807 ToolkitTestApplication application;
2808 tet_infoline(" utcDaliTextLabelGeometryRTL");
2810 TextLabel label = TextLabel::New();
2811 DALI_TEST_CHECK(label);
2813 application.GetScene().Add(label);
2815 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2816 label.SetProperty(Actor::Property::SIZE, Vector2(150.f, 100.f));
2817 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2818 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2819 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2820 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2821 label.SetProperty(TextLabel::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر");
2822 // Avoid a crash when core load gl resources.
2823 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2825 // Render and notify
2826 application.SendNotification();
2827 application.Render();
2829 unsigned int expectedCount = 4;
2830 unsigned int startIndex = 3;
2831 unsigned int endIndex = 24;
2833 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2834 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2836 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2837 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2839 Vector<Vector2> expectedSizes;
2840 Vector<Vector2> expectedPositions;
2842 expectedPositions.PushBack(Vector2(25, 0));
2843 expectedSizes.PushBack(Vector2(34, 25));
2845 expectedPositions.PushBack(Vector2(-1, 25));
2846 expectedSizes.PushBack(Vector2(53, 25));
2848 expectedPositions.PushBack(Vector2(-1, 50));
2849 expectedSizes.PushBack(Vector2(60, 25));
2851 expectedPositions.PushBack(Vector2(75, 75));
2852 expectedSizes.PushBack(Vector2(37, 25));
2854 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2859 int utcDaliTextLabelGeometryGlyphMiddle(void)
2861 ToolkitTestApplication application;
2862 tet_infoline(" utcDaliTextLabelGeometryGlyphMiddle");
2864 TextLabel label = TextLabel::New();
2865 DALI_TEST_CHECK(label);
2867 application.GetScene().Add(label);
2869 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2870 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2871 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2872 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2873 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2874 label.SetProperty(TextLabel::Property::TEXT, "لا تحتوي على لا");
2876 // Avoid a crash when core load gl resources.
2877 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2879 // Render and notify
2880 application.SendNotification();
2881 application.Render();
2883 unsigned int expectedCount = 1;
2884 unsigned int startIndex = 1;
2885 unsigned int endIndex = 13;
2887 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2888 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2890 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2891 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2893 Vector<Vector2> expectedSizes;
2894 Vector<Vector2> expectedPositions;
2896 expectedPositions.PushBack(Vector2(6, 0));
2897 expectedSizes.PushBack(Vector2(125, 25));
2899 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2904 int utcDaliTextLabelGeometryOneGlyph(void)
2906 ToolkitTestApplication application;
2907 tet_infoline(" utcDaliTextLabelGeometryOneGlyph ");
2909 TextLabel label = TextLabel::New();
2910 DALI_TEST_CHECK(label);
2912 application.GetScene().Add(label);
2914 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2915 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2916 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2917 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2918 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2919 label.SetProperty(TextLabel::Property::TEXT, "H");
2921 // Avoid a crash when core load gl resources.
2922 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2924 // Render and notify
2925 application.SendNotification();
2926 application.Render();
2928 unsigned int expectedCount = 1;
2929 unsigned int startIndex = 0;
2930 unsigned int endIndex = 0;
2932 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2933 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2935 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2936 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2938 Vector<Vector2> expectedSizes;
2939 Vector<Vector2> expectedPositions;
2941 expectedPositions.PushBack(Vector2(-2, 0));
2942 expectedSizes.PushBack(Vector2(16, 25));
2944 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2946 positionsList.Clear();
2952 positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2953 sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2955 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2960 int utcDaliTextLabelGeometryNullPtr(void)
2962 ToolkitTestApplication application;
2963 tet_infoline("utcDaliTextLabelGeometryNullPtr");
2965 TextLabel label = TextLabel::New();
2966 DALI_TEST_CHECK(label);
2968 application.GetScene().Add(label);
2970 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2971 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2972 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2973 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2974 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2975 label.SetProperty(TextLabel::Property::TEXT, "");
2977 // Avoid a crash when core load gl resources.
2978 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2980 unsigned int expectedCount = 0;
2981 unsigned int startIndex = 0;
2982 unsigned int endIndex = 0;
2984 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2985 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2987 // Render and notify
2988 application.SendNotification();
2989 application.Render();
2991 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2992 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2997 int UtcDaliToolkitTextlabelEllipsisPositionProperty(void)
2999 ToolkitTestApplication application;
3000 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty ");
3001 TextLabel textLabel = TextLabel::New();
3003 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Default is END");
3004 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3006 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START");
3007 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
3008 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3010 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE");
3011 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
3012 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3014 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END");
3015 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
3016 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3018 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using integer");
3019 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 1);
3020 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3022 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using integer");
3023 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 2);
3024 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3026 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using integer");
3027 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 0);
3028 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3030 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
3031 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "START");
3032 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3034 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
3035 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "MIDDLE");
3036 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3038 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
3039 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "END");
3040 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3042 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
3043 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "start");
3044 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3046 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
3047 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "middle");
3048 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3050 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
3051 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "end");
3052 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3057 int UtcDaliToolkitTextLabelStrikethroughGeneration(void)
3059 ToolkitTestApplication application;
3060 tet_infoline(" UtcDaliToolkitTextLabelStrikethroughGeneration");
3062 TextLabel textLabel = TextLabel::New();
3063 textLabel.SetProperty(TextLabel::Property::TEXT, "Test");
3064 textLabel.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
3065 textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3066 textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
3068 application.GetScene().Add(textLabel);
3069 application.SendNotification();
3070 application.Render();
3072 Property::Map strikethroughMapSet;
3073 Property::Map strikethroughMapGet;
3075 strikethroughMapSet.Insert("enable", true);
3076 strikethroughMapSet.Insert("color", Color::RED);
3077 strikethroughMapSet.Insert("height", 2.0f);
3079 // Check the strikethrough property
3080 textLabel.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
3081 strikethroughMapGet = textLabel.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
3082 textLabel.SetProperty(TextLabel::Property::TEXT, "Test1");
3083 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
3084 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
3086 // Render and notify
3087 application.SendNotification();
3088 application.Render();
3090 strikethroughMapSet.Clear();
3091 strikethroughMapGet.Clear();
3096 int UtcDaliToolkitTextLabelMarkupRelativeLineHeight(void)
3098 ToolkitTestApplication application;
3099 tet_infoline(" UtcDaliToolkitTextLabelMarkupRelativeLineHeight");
3101 TextLabel label = TextLabel::New();
3102 label.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3103 label.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3104 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3105 label.SetProperty(TextLabel::Property::TEXT, "line 1\nline 2\nline 3\nline 4\nline 5");
3106 label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3107 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
3108 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3110 TextLabel labelSingleLineParagraph = TextLabel::New();
3111 labelSingleLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3112 labelSingleLineParagraph.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3113 labelSingleLineParagraph.SetProperty(TextLabel::Property::MULTI_LINE, true);
3114 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");
3115 labelSingleLineParagraph.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3116 labelSingleLineParagraph.SetProperty(TextLabel::Property::ELLIPSIS, false);
3117 labelSingleLineParagraph.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3119 TextLabel labelMultiLineParagraph = TextLabel::New();
3120 labelMultiLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3121 labelMultiLineParagraph.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3122 labelMultiLineParagraph.SetProperty(TextLabel::Property::MULTI_LINE, true);
3123 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");
3124 labelMultiLineParagraph.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3125 labelMultiLineParagraph.SetProperty(TextLabel::Property::ELLIPSIS, false);
3126 labelMultiLineParagraph.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3128 application.GetScene().Add(label);
3129 application.GetScene().Add(labelSingleLineParagraph);
3130 application.GetScene().Add(labelMultiLineParagraph);
3131 application.SendNotification();
3132 application.Render();
3134 Vector3 naturalSize = label.GetNaturalSize();
3135 Vector3 relativeSingleNaturalSize = labelSingleLineParagraph.GetNaturalSize();
3136 Vector3 relativeMultiNaturalSize = labelMultiLineParagraph.GetNaturalSize();
3138 float lineSize = naturalSize.y / 5.0f; //total size/number of lines
3140 //no effect of relative line size for paragraph with single line
3141 DALI_TEST_EQUALS(naturalSize.y, relativeSingleNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3143 DALI_TEST_EQUALS(lineSize * 8.5f, relativeMultiNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3148 int UtcDaliToolkitTextLabelRelativeLineHeight(void)
3150 ToolkitTestApplication application;
3151 tet_infoline(" UtcDaliToolkitTextLabelRelativeLineHeight");
3153 TextLabel label = TextLabel::New();
3154 label.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3155 label.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3156 label.SetProperty(TextLabel::Property::TEXT, "Hello\nWorld");
3158 application.GetScene().Add(label);
3159 application.SendNotification();
3160 application.Render();
3162 Vector3 naturalSize = label.GetNaturalSize();
3164 label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 0.5f);
3166 application.SendNotification();
3167 application.Render();
3169 Vector3 relativeNaturalSize = label.GetNaturalSize();
3171 DALI_TEST_EQUALS(naturalSize.y, relativeNaturalSize.y, TEST_LOCATION);
3173 label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 2.0f);
3175 application.SendNotification();
3176 application.Render();
3178 relativeNaturalSize = label.GetNaturalSize();
3180 DALI_TEST_EQUALS(naturalSize.y * 2, relativeNaturalSize.y, TEST_LOCATION);
3184 int UtcDaliTextLabelCharacterSpacing(void)
3186 ToolkitTestApplication application;
3187 tet_infoline(" UtcDaliTextLabelCharacterSpacing ");
3189 TextLabel textLabel = TextLabel::New();
3191 textLabel.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
3193 application.GetScene().Add(textLabel);
3194 application.SendNotification();
3195 application.Render();
3197 textLabel.SetProperty(TextLabel::Property::TEXT, "Hi Experiment");
3198 textLabel.SetProperty(DevelTextLabel::Property::CHARACTER_SPACING, 10.f);
3199 DALI_TEST_EQUALS(textLabel.GetProperty<float>(DevelTextLabel::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3201 application.SendNotification();
3202 application.Render();
3207 int UtcDaliTextTextLabelSizeNegativeLineSpacing(void)
3209 ToolkitTestApplication application;
3210 tet_infoline("UtcDaliTextTextLabelSizeNegativeLineSpacing");
3212 TextLabel label = TextLabel::New();
3214 float lineSpacing = -20.f;
3216 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
3217 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
3218 label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
3219 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3220 label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
3222 application.GetScene().Add(label);
3223 application.SendNotification();
3224 application.Render();
3226 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, 0, 123);
3227 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, 0, 123);
3229 Vector2 lastLinePos = positionsList[positionsList.Size() - 1];
3230 Vector2 lastLineSize = sizeList[sizeList.Size() - 1];
3232 DALI_TEST_EQUALS(sizeList[0].y * (sizeList.Size() - 1), lastLinePos.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3233 DALI_TEST_EQUALS(sizeList[0].y - lineSpacing, lastLineSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3235 application.SendNotification();
3236 application.Render();
3241 int UtcDaliTextLabelNegativeLineSpacingWithEllipsis(void)
3243 ToolkitTestApplication application;
3244 tet_infoline("UtcDaliTextLabelNegativeLineSpacingWithEllipsis");
3246 TextLabel label = TextLabel::New();
3248 float lineSpacing = -20.f;
3250 label.SetProperty(Actor::Property::SIZE, Vector2(480.0f, 100.f));
3251 label.SetProperty(TextLabel::Property::POINT_SIZE, 11.0f);
3252 label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
3253 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3254 label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
3255 label.SetProperty(TextLabel::Property::ELLIPSIS, true);
3257 application.GetScene().Add(label);
3258 application.SendNotification();
3259 application.Render();
3261 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, 0, 123);
3263 int lineCount = sizeList.Size();
3264 DALI_TEST_EQUALS(4, lineCount, TEST_LOCATION);
3266 application.SendNotification();
3267 application.Render();
3272 int UtcDaliToolkitTextlabelParagraphTag(void)
3274 ToolkitTestApplication application;
3275 tet_infoline(" UtcDaliToolkitTextlabelParagraphTag");
3276 TextLabel labelNewlineSeparator = TextLabel::New();
3277 TextLabel labelParagraphTag = TextLabel::New();
3278 DALI_TEST_CHECK(labelNewlineSeparator);
3279 DALI_TEST_CHECK(labelParagraphTag);
3281 application.GetScene().Add(labelNewlineSeparator);
3282 application.GetScene().Add(labelParagraphTag);
3284 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
3285 labelNewlineSeparator.SetProperty(TextLabel::Property::MULTI_LINE, true);
3286 labelNewlineSeparator.SetProperty(TextLabel::Property::ELLIPSIS, false);
3287 labelNewlineSeparator.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3288 labelNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3289 labelNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3290 labelNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3291 labelNewlineSeparator.SetProperty(TextLabel::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
3293 labelParagraphTag.SetProperty(TextLabel::Property::MULTI_LINE, true);
3294 labelParagraphTag.SetProperty(TextLabel::Property::ELLIPSIS, false);
3295 labelParagraphTag.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3296 labelParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3297 labelParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3298 labelParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3299 labelParagraphTag.SetProperty(TextLabel::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
3301 application.SendNotification();
3302 application.Render();
3304 Vector3 textNaturalSizeNewlineSeparator = labelNewlineSeparator.GetNaturalSize();
3305 Vector3 textNaturalSizeParagraphTag = labelParagraphTag.GetNaturalSize();
3307 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
3309 application.SendNotification();
3310 application.Render();
3315 int utcDaliTextLabelGetTextBoundingRectangle(void)
3317 ToolkitTestApplication application;
3318 tet_infoline(" utcDaliTextLabelGeometryEllipsisMiddle");
3320 TextLabel label = TextLabel::New();
3321 DALI_TEST_CHECK(label);
3323 application.GetScene().Add(label);
3325 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
3326 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3327 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3328 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3329 label.SetProperty(TextLabel::Property::TEXT, "Hello this is the Text Bounding Rectangle TC");
3331 // Avoid a crash when core load gl resources.
3332 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3334 // Render and notify
3335 application.SendNotification();
3336 application.Render();
3338 unsigned int startIndex = 0;
3339 unsigned int endIndex = 15;
3341 Rect<> textBoundingRectangle = DevelTextLabel::GetTextBoundingRectangle(label, startIndex, endIndex);
3342 Rect<> expectedTextBoundingRectangle = {0, 0, 100, 25};
3344 TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);
3349 int utcDaliTextLabelRemoveFrontInset(void)
3351 ToolkitTestApplication application;
3352 tet_infoline(" utcDaliTextLabelRemoveFrontInset");
3354 TextLabel label = TextLabel::New();
3355 DALI_TEST_CHECK(label);
3357 application.GetScene().Add(label);
3358 application.SendNotification();
3359 application.Render();
3361 DevelTextLabel::SetRemoveFrontInset(label, false);
3362 DALI_TEST_CHECK(!DevelTextLabel::IsRemoveFrontInset(label));
3367 int utcDaliTextLabelRemoveBackInset(void)
3369 ToolkitTestApplication application;
3370 tet_infoline(" utcDaliTextLabelRemoveBackInset");
3372 TextLabel label = TextLabel::New();
3373 DALI_TEST_CHECK(label);
3375 application.GetScene().Add(label);
3376 application.SendNotification();
3377 application.Render();
3379 DevelTextLabel::SetRemoveBackInset(label, false);
3380 DALI_TEST_CHECK(!DevelTextLabel::IsRemoveBackInset(label));