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 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
957 outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
958 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
959 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
961 outlineMapSet.Clear();
962 outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
963 outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
964 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
966 outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
967 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
968 std::vector<std::string> outlineIndicesConversionTable = {"color", "width"};
969 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet, outlineIndicesConversionTable), true, TEST_LOCATION);
971 // Check the background property
972 Property::Map backgroundMapSet;
973 Property::Map backgroundMapGet;
975 backgroundMapSet["enable"] = true;
976 backgroundMapSet["color"] = Color::RED;
977 label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
979 backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
980 DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
981 DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet), true, TEST_LOCATION);
983 // Check the transparent background property for coverage
984 backgroundMapSet.Clear();
985 backgroundMapSet["enable"] = true;
986 backgroundMapSet["color"] = Color::TRANSPARENT;
987 label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
989 application.SendNotification();
990 application.Render();
992 backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
993 DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
994 DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet), true, TEST_LOCATION);
996 backgroundMapSet.Clear();
997 backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
998 backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
999 label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
1001 backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
1002 DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
1003 std::vector<std::string> backgroundIndicesConversionTable = {"enable", "color"};
1004 DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable), true, TEST_LOCATION);
1006 // Check the pixel size of font
1007 label.SetProperty(TextLabel::Property::PIXEL_SIZE, 20.f);
1008 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1010 // Check the ellipsis property
1011 DALI_TEST_CHECK(label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
1012 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
1013 DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
1015 // Check the layout direction property
1016 label.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1017 DALI_TEST_EQUALS(label.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1019 // Check the line size property
1020 DALI_TEST_EQUALS(label.GetProperty<float>(DevelTextLabel::Property::MIN_LINE_SIZE), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1021 label.SetProperty(DevelTextLabel::Property::MIN_LINE_SIZE, 50.f);
1022 DALI_TEST_EQUALS(label.GetProperty<float>(DevelTextLabel::Property::MIN_LINE_SIZE), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1024 application.SendNotification();
1025 application.Render();
1027 // Check Remove Front/Back Inset Property
1028 DALI_TEST_CHECK(label.GetProperty<bool>(DevelTextLabel::Property::REMOVE_FRONT_INSET));
1029 label.SetProperty(DevelTextLabel::Property::REMOVE_FRONT_INSET, false);
1030 DALI_TEST_CHECK(!label.GetProperty<bool>(DevelTextLabel::Property::REMOVE_FRONT_INSET));
1032 DALI_TEST_CHECK(label.GetProperty<bool>(DevelTextLabel::Property::REMOVE_BACK_INSET));
1033 label.SetProperty(DevelTextLabel::Property::REMOVE_BACK_INSET, false);
1034 DALI_TEST_CHECK(!label.GetProperty<bool>(DevelTextLabel::Property::REMOVE_BACK_INSET));
1036 application.SendNotification();
1037 application.Render();
1042 int UtcDaliToolkitTextlabelAtlasRenderP(void)
1044 ToolkitTestApplication application;
1045 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
1046 TextLabel label = TextLabel::New("Test Text");
1047 DALI_TEST_CHECK(label);
1049 // Avoid a crash when core load gl resources.
1050 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1052 application.GetScene().Add(label);
1054 // Turn on all the effects
1055 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1056 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1058 Property::Map underlineMap;
1059 underlineMap.Insert("enable", true);
1060 underlineMap.Insert("color", Color::RED);
1061 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMap);
1063 Property::Map shadowMap;
1064 shadowMap.Insert("color", Color::BLUE);
1065 shadowMap.Insert("offset", Vector2(1.0f, 1.0f));
1066 label.SetProperty(TextLabel::Property::SHADOW, shadowMap);
1068 Property::Map strikethroughMap;
1069 strikethroughMap.Insert("enable", true);
1070 strikethroughMap.Insert("color", Color::GREEN);
1071 strikethroughMap.Insert("height", 2.0f);
1072 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMap);
1076 // Render some text with the shared atlas backend
1077 label.SetProperty(DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1078 application.SendNotification();
1079 application.Render();
1083 tet_result(TET_FAIL);
1088 // Render some text with the shared atlas backend
1089 label.SetProperty(DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED);
1090 application.SendNotification();
1091 application.Render();
1095 tet_result(TET_FAIL);
1100 int UtcDaliToolkitTextLabelLanguagesP(void)
1102 ToolkitTestApplication application;
1103 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
1104 TextLabel label = TextLabel::New();
1105 DALI_TEST_CHECK(label);
1107 application.GetScene().Add(label);
1109 const std::string scripts(
1110 " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
1111 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
1112 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
1113 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
1114 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
1115 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84."); // these characters on the last line are emojis.
1117 label.SetProperty(TextLabel::Property::TEXT, scripts);
1118 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::TEXT), scripts, TEST_LOCATION);
1120 application.SendNotification();
1121 application.Render();
1126 int UtcDaliToolkitTextLabelEmojisP(void)
1128 ToolkitTestApplication application;
1129 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
1130 TextLabel label = TextLabel::New();
1131 DALI_TEST_CHECK(label);
1133 application.GetScene().Add(label);
1135 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1137 char* pathNamePtr = get_current_dir_name();
1138 const std::string pathName(pathNamePtr);
1141 TextAbstraction::FontDescription fontDescription;
1142 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
1143 fontDescription.family = "BreezeColorEmoji";
1144 fontDescription.width = TextAbstraction::FontWidth::NONE;
1145 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
1146 fontDescription.slant = TextAbstraction::FontSlant::NONE;
1148 fontClient.GetFontId(fontDescription, EMOJI_FONT_SIZE);
1150 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>";
1151 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1152 label.SetProperty(TextLabel::Property::TEXT, emojis);
1154 Property::Map shadowMap;
1155 shadowMap.Insert("color", "green");
1156 shadowMap.Insert("offset", "2 2");
1157 label.SetProperty(TextLabel::Property::SHADOW, shadowMap);
1159 application.SendNotification();
1160 application.Render();
1162 // EMOJI + ZWJ + EMOJI case for coverage.
1163 const std::string emojiWithZWJ = "👩‍🔬";
1164 label.SetProperty(TextLabel::Property::TEXT, emojiWithZWJ);
1166 application.SendNotification();
1167 application.Render();
1169 // EMOJI Sequences case for coverage.
1170 std::string emojiSequences =
1171 "Glyphs not included in the font \n" //case for coverage when glyph is not included in the font
1172 "Text VS15 ☪︎\n" //text presentation sequence and selector
1173 "Color VS16 ☪️\n" //emoji presentation sequence and selector
1174 "Default ☪ \n" //default presentation
1175 "FamilyManWomanGirlBoy 👨‍👩‍👧‍👦\n" // emoji multi zwj sequence
1176 "WomanScientist 👩‍🔬\n" // emoji zwj sequence
1177 "WomanScientistLightSkinTone👩🏻‍🔬 \n" // emoji modifier sequence: skin tone & JWZ
1178 "LeftRightArrowText↔︎\n" // text presentation sequence and selector
1179 "LeftRightArrowEmoji↔️\n" // emoji presentation sequence and selector
1180 "SouthKoreaFlag🇰🇷\n" // emoji flag sequence
1181 "JordanFlag🇯🇴\n" // emoji flag sequence
1182 "EnglandFlag🏴󠁧󠁢󠁥󠁮󠁧󠁿\n" // emoji tag sequence like England flag
1183 "Runner 🏃‍➡️ \n"
1184 "VictoryHandMediumLightSkinTone:✌️🏼\n" // emoji modifier sequence: skin tone
1185 "RainbowFlag:🏳️‍🌈 \n" // emoji zwj sequence: Rainbow Flag
1186 "keycap# #️⃣ \n" // fully-qualified emoji keycap sequence
1187 "keycap#_text #⃣ \n" // unqualified emoji keycap sequence
1188 "keycap3 3️⃣ \n" // fully-qualified emoji keycap sequence
1189 "keycap3_text 3⃣ \n" // unqualified emoji keycap sequence
1190 "two adjacent glyphs ☪️️️☪️\n" // This line should be rendered as two adjacent glyphs
1191 "Digit 8️ 8︎ 8\n" // should be rendered according to selector
1192 "Surfing Medium Skin Female: 🏄🏼‍♀️\n" // Person Surfing + Medium Skin Tone +? Zero Width Joiner + Female Sign
1193 "SYMBOLS_NSLCL variation selector: 🅰️🅱️🅲︎🅳︎🅴︎\n" // 1F170 ~ 1F174 with variation selector, text vs emoji
1194 "SYMBOLS_NSLCL with VS15: 🅰︎🅱︎🅲︎🅳︎🅴︎\n" // 1F170 ~ 1F174 with VS15
1195 "SYMBOLS_NSLCL with VS16: 🅰️🅱️🅲️🅳️🅴️\n" // 1F170 ~ 1F174 with VS16
1199 label.SetProperty(TextLabel::Property::TEXT, emojiSequences);
1200 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1201 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1202 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
1204 application.SendNotification();
1205 application.Render();
1209 int UtcDaliToolkitTextlabelScrollingP(void)
1211 ToolkitTestApplication application;
1212 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
1213 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
1214 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
1216 DALI_TEST_CHECK(labelImmediate);
1217 DALI_TEST_CHECK(labelFinished);
1218 // Avoid a crash when core load gl resources.
1219 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1220 application.GetScene().Add(labelImmediate);
1221 // Turn on all the effects
1222 labelImmediate.SetProperty(TextLabel::Property::MULTI_LINE, false);
1223 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1224 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1225 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1226 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1228 application.GetScene().Add(labelFinished);
1229 // Turn on all the effects
1230 labelFinished.SetProperty(TextLabel::Property::MULTI_LINE, false);
1231 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1232 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1233 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1234 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1238 // Render some text with the shared atlas backend
1239 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1240 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1242 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1243 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1245 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1246 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1247 application.SendNotification();
1248 application.Render();
1250 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1251 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1252 application.SendNotification();
1253 application.Render();
1257 tet_result(TET_FAIL);
1263 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
1265 ToolkitTestApplication application;
1266 TextLabel labelShort = TextLabel::New("Some text to scroll");
1267 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!");
1269 DALI_TEST_CHECK(labelShort);
1270 DALI_TEST_CHECK(labelLong);
1271 // Avoid a crash when core load gl resources.
1272 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1273 application.GetScene().Add(labelShort);
1274 // Turn on all the effects
1275 labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1276 labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1277 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1278 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1279 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1280 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1282 application.GetScene().Add(labelLong);
1283 // Turn on all the effects
1284 labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1285 labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1286 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1287 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1288 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1289 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1293 // Render some text with the shared atlas backend
1294 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1295 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1296 application.SendNotification();
1297 application.Render();
1299 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1300 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1301 application.SendNotification();
1302 application.Render();
1306 tet_result(TET_FAIL);
1312 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
1314 ToolkitTestApplication application;
1315 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1316 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1318 DALI_TEST_CHECK(labelShort);
1319 DALI_TEST_CHECK(labelLong);
1320 // Avoid a crash when core load gl resources.
1321 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1322 application.GetScene().Add(labelShort);
1323 // Turn on all the effects
1324 labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1325 labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1326 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1327 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1328 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1329 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1331 application.GetScene().Add(labelLong);
1332 // Turn on all the effects
1333 labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1334 labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1335 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1336 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1337 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1338 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1342 // Render some text with the shared atlas backend
1343 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1344 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1345 application.SendNotification();
1346 application.Render();
1348 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1349 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1350 application.SendNotification();
1351 application.Render();
1355 tet_result(TET_FAIL);
1361 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
1363 ToolkitTestApplication application;
1364 TextLabel labelShort = TextLabel::New("Some text to scroll");
1365 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!");
1367 DALI_TEST_CHECK(labelShort);
1368 DALI_TEST_CHECK(labelLong);
1369 // Avoid a crash when core load gl resources.
1370 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1371 application.GetScene().Add(labelShort);
1372 // Turn on all the effects
1373 labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1374 labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1375 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1376 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1377 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1378 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1380 application.GetScene().Add(labelLong);
1381 // Turn on all the effects
1382 labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1383 labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1384 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1385 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1386 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1387 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1391 // Render some text with the shared atlas backend
1392 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1393 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1394 application.SendNotification();
1395 application.Render();
1397 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1398 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1399 application.SendNotification();
1400 application.Render();
1404 tet_result(TET_FAIL);
1410 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
1412 ToolkitTestApplication application;
1413 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1414 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1416 DALI_TEST_CHECK(labelShort);
1417 DALI_TEST_CHECK(labelLong);
1418 // Avoid a crash when core load gl resources.
1419 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1420 application.GetScene().Add(labelShort);
1421 // Turn on all the effects
1422 labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1423 labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1424 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1425 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1426 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1427 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1429 application.GetScene().Add(labelLong);
1430 // Turn on all the effects
1431 labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1432 labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1433 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1434 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1435 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1436 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1440 // Render some text with the shared atlas backend
1441 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1442 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1443 application.SendNotification();
1444 application.Render();
1446 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1447 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1448 application.SendNotification();
1449 application.Render();
1453 tet_result(TET_FAIL);
1459 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1461 ToolkitTestApplication application;
1462 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1463 TextLabel label = TextLabel::New("Some text to scroll");
1464 DALI_TEST_CHECK(label);
1465 // Avoid a crash when core load gl resources.
1466 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1467 application.GetScene().Add(label);
1468 label.SetProperty(Actor::Property::SIZE, Vector2(360.0f, 20.f));
1469 // Turn on all the effects
1470 label.SetProperty(TextLabel::Property::MULTI_LINE, false);
1471 label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1472 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1473 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1476 application.SendNotification();
1477 application.Render();
1479 unsigned int actorCount1 = label.GetChildCount();
1480 tet_printf("Initial actor count is(%d)\n", actorCount1);
1484 // Render some text with the shared atlas backend
1485 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1486 application.SendNotification();
1487 application.Render(2000);
1489 unsigned int actorCount1 = label.GetChildCount();
1490 tet_printf("Actor count after scrolling is(%d)\n", actorCount1);
1492 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1495 application.SendNotification();
1496 application.Render();
1498 unsigned int actorCount2 = label.GetChildCount();
1499 tet_printf("After changing color the actor count is(%d)\n", actorCount2);
1501 DALI_TEST_EQUALS(actorCount1, actorCount2, TEST_LOCATION);
1505 tet_result(TET_FAIL);
1511 int UtcDaliToolkitTextlabelScrollingN(void)
1513 ToolkitTestApplication application;
1514 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1516 TextLabel label = TextLabel::New("Some text to scroll");
1517 DALI_TEST_CHECK(label);
1519 application.GetScene().Add(label);
1521 // Avoid a crash when core load gl resources.
1522 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1524 // The text scrolling works only on single line text.
1525 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1527 // Turn on all the effects.
1528 label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1529 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1530 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1532 // Enable the auto scrolling effect.
1533 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1535 // The auto scrolling shouldn't be enabled.
1536 const bool enabled = label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>();
1537 DALI_TEST_CHECK(!enabled);
1539 label.SetProperty(TextLabel::Property::MULTI_LINE, false);
1540 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 1);
1541 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 9999.0f);
1542 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1547 application.SendNotification();
1548 application.Render(1000);
1550 application.GetScene().Remove(label);
1551 application.SendNotification();
1552 application.Render();
1554 DALI_TEST_CHECK(!label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
1556 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1557 application.GetScene().Add(label);
1559 application.SendNotification();
1560 application.Render();
1562 DALI_TEST_CHECK(label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
1564 label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, (Toolkit::TextLabel::AutoScrollStopMode::Type)2); // invalid type
1565 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1567 application.SendNotification();
1568 application.Render();
1570 DALI_TEST_CHECK(label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
1574 tet_result(TET_FAIL);
1580 int UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
1582 ToolkitTestApplication application;
1583 tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
1585 TextLabel label = TextLabel::New("Some text to scroll");
1586 DALI_TEST_CHECK(label);
1588 application.GetScene().Add(label);
1590 // Avoid a crash when core load gl resources.
1591 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1593 // Turn on all the effects.
1594 label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1595 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1596 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1600 // Enable the auto scrolling effect.
1601 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1602 label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1604 // Disable the ellipsis
1605 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
1608 application.SendNotification();
1609 application.Render();
1611 // Stop auto scrolling
1612 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1614 // Check the ellipsis property
1615 DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
1619 tet_result(TET_FAIL);
1625 int UtcDaliToolkitTextlabelEllipsis(void)
1627 ToolkitTestApplication application;
1628 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1630 TextLabel label = TextLabel::New("Hello world");
1631 DALI_TEST_CHECK(label);
1633 // Avoid a crash when core load gl resources.
1634 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1636 application.GetScene().Add(label);
1638 // Turn on all the effects
1639 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1640 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1641 label.SetProperty(Actor::Property::SIZE, Vector2(360.0f, 10.f));
1646 application.SendNotification();
1647 application.Render();
1651 tet_result(TET_FAIL);
1654 label.SetProperty(TextLabel::Property::TEXT, "Hello world ");
1655 label.SetProperty(DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false);
1656 label.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 10.f));
1661 application.SendNotification();
1662 application.Render();
1666 tet_result(TET_FAIL);
1669 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1670 label.SetProperty(DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
1671 label.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 10.f));
1676 application.SendNotification();
1677 application.Render();
1681 tet_result(TET_FAIL);
1687 int UtcDaliToolkitTextlabelTextWrapMode(void)
1689 ToolkitTestApplication application;
1690 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1694 TextLabel label = TextLabel::New();
1695 label.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.f));
1696 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1697 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1699 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1700 application.GetScene().Add(label);
1702 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "WORD");
1703 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
1705 application.SendNotification();
1706 application.Render();
1708 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1709 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1711 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
1712 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1714 application.SendNotification();
1715 application.Render();
1717 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD);
1718 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
1720 application.SendNotification();
1721 application.Render();
1723 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1724 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1726 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER);
1727 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1729 application.SendNotification();
1730 application.Render();
1732 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1733 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1735 tet_infoline("Ensure invalid string does not change wrapping mode");
1736 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode");
1737 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1742 int UtcDaliToolkitTextLabelColorComponents(void)
1744 ToolkitTestApplication application;
1746 TextLabel label = TextLabel::New();
1747 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1748 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 1.0f, TEST_LOCATION);
1749 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 0.0f, TEST_LOCATION);
1750 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 0.0f, TEST_LOCATION);
1751 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1753 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::GREEN);
1754 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 0.0f, TEST_LOCATION);
1755 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 1.0f, TEST_LOCATION);
1756 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 0.0f, TEST_LOCATION);
1757 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1759 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLUE);
1760 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 0.0f, TEST_LOCATION);
1761 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 0.0f, TEST_LOCATION);
1762 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 1.0f, TEST_LOCATION);
1763 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1765 label.SetProperty(TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f);
1766 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 0.6f, TEST_LOCATION);
1767 DALI_TEST_EQUALS(label.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR), Vector4(0.0f, 0.0f, 1.0f, 0.6f), TEST_LOCATION);
1769 // Test a transparent text - Rendering should be skipped.
1770 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1771 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLUE);
1773 application.GetScene().Add(label);
1775 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1776 drawTrace.Enable(true);
1778 application.SendNotification();
1779 application.Render();
1781 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION); // Should be rendered
1783 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT);
1787 application.SendNotification();
1788 application.Render();
1790 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), false, TEST_LOCATION); // Rendering should be skipped
1792 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1796 application.SendNotification();
1797 application.Render();
1799 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION); // Should be rendered again
1804 int UtcDaliToolkitTextlabelTextStyle01(void)
1806 ToolkitTestApplication application;
1807 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1809 TextLabel label = TextLabel::New();
1810 label.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.f));
1811 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1812 label.SetProperty(TextLabel::Property::POINT_SIZE, 12);
1813 application.GetScene().Add(label);
1815 Property::Map outlineMapSet;
1816 Property::Map outlineMapGet;
1818 outlineMapSet["color"] = Color::BLUE;
1819 outlineMapSet["width"] = 2.0f;
1820 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
1822 application.SendNotification();
1823 application.Render();
1825 Property::Map shadowMapSet;
1826 shadowMapSet.Insert("color", "green");
1827 shadowMapSet.Insert("offset", "2 2");
1828 shadowMapSet.Insert("blurRadius", "3");
1829 label.SetProperty(TextLabel::Property::SHADOW, shadowMapSet);
1831 outlineMapSet["color"] = Color::RED;
1832 outlineMapSet["width"] = 0.0f;
1833 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
1835 application.SendNotification();
1836 application.Render();
1838 outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
1840 Property::Value* colorValue = outlineMapGet.Find("color");
1842 bool colorMatched(false);
1846 Property::Type valueType = colorValue->GetType();
1848 if(Property::STRING == valueType)
1850 std::string stringValue;
1851 colorValue->Get(stringValue);
1852 if(stringValue == "red")
1854 colorMatched = true;
1857 else if(Property::VECTOR4 == valueType)
1859 Vector4 colorVector4;
1860 colorValue->Get(colorVector4);
1861 if(colorVector4 == Color::RED)
1863 colorMatched = true;
1868 DALI_TEST_EQUALS(colorMatched, true, TEST_LOCATION);
1873 int UtcDaliToolkitTextlabelMultiline(void)
1875 ToolkitTestApplication application;
1876 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1878 TextLabel label = TextLabel::New();
1879 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world");
1880 label.SetProperty(TextLabel::Property::POINT_SIZE, 20);
1881 label.SetProperty(TextLabel::Property::MULTI_LINE, false);
1882 application.GetScene().Add(label);
1884 application.SendNotification();
1885 application.Render();
1887 int lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1888 DALI_TEST_EQUALS(lineCount, 1, TEST_LOCATION);
1890 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1892 application.SendNotification();
1893 application.Render();
1895 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1896 DALI_TEST_EQUALS(true, (lineCount > 1), TEST_LOCATION);
1901 int UtcDaliToolkitTextlabelTextDirection(void)
1903 ToolkitTestApplication application;
1904 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1906 TextLabel label = TextLabel::New();
1907 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT), TEST_LOCATION);
1909 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1910 label.SetProperty(TextLabel::Property::POINT_SIZE, 20);
1911 label.SetProperty(DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
1912 application.GetScene().Add(label);
1915 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT), TEST_LOCATION);
1918 label.SetProperty(TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ");
1919 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1921 // Test RTL text starting with weak character
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 string with emoji and weak character
1926 label.SetProperty(TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ");
1927 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1932 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1934 ToolkitTestApplication application;
1935 tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1937 TextLabel label = TextLabel::New();
1939 label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP);
1940 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1941 label.SetProperty(TextLabel::Property::POINT_SIZE, 15);
1942 label.SetProperty(TextLabel::Property::LINE_SPACING, 12);
1943 application.GetScene().Add(label);
1944 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::TOP), TEST_LOCATION);
1946 label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE);
1947 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::MIDDLE), TEST_LOCATION);
1949 label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM);
1950 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::BOTTOM), TEST_LOCATION);
1955 int UtcDaliToolkitTextLabelBitmapFont(void)
1957 ToolkitTestApplication application;
1958 tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1960 DevelText::BitmapFontDescription fontDescription;
1961 fontDescription.name = "Digits";
1962 fontDescription.underlinePosition = 0.f;
1963 fontDescription.underlineThickness = 0.f;
1965 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f});
1966 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f});
1967 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f});
1968 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f});
1969 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f});
1970 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f});
1971 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f});
1972 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f});
1973 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f});
1974 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f});
1975 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f});
1977 TextAbstraction::BitmapFont bitmapFont;
1978 DevelText::CreateBitmapFont(fontDescription, bitmapFont);
1980 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1981 fontClient.GetFontId(bitmapFont);
1983 TextLabel label = TextLabel::New();
1985 label.SetProperty(TextLabel::Property::TEXT, "0123456789:");
1986 label.SetProperty(TextLabel::Property::FONT_FAMILY, "Digits");
1988 // 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.
1989 DALI_TEST_EQUALS(label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1991 application.GetScene().Add(label);
1993 application.SendNotification();
1994 application.Render();
1996 // The text has been rendered if the height of the text-label is the height of the line.
1997 DALI_TEST_EQUALS(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2002 int ConvertPointToPixel(float point)
2004 unsigned int horizontalDpi = 0u;
2005 unsigned int verticalDpi = 0u;
2006 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2007 fontClient.GetDpi(horizontalDpi, verticalDpi);
2009 return (point * 72.f) / static_cast<float>(horizontalDpi);
2012 int UtcDaliToolkitTextlabelTextFit(void)
2014 ToolkitTestApplication application;
2015 tet_infoline(" UtcDaliToolkitTextlabelTextFit");
2016 TextLabel label = TextLabel::New();
2017 Vector2 size(460.0f, 100.0f);
2018 label.SetProperty(Actor::Property::SIZE, size);
2019 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
2021 // connect to the text git changed signal.
2022 ConnectionTracker* testTracker = new ConnectionTracker();
2023 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2024 bool textFitChangedSignal = false;
2025 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2026 gTextFitChangedCallBackCalled = false;
2029 Property::Map textFitMapSet;
2030 textFitMapSet["enable"] = true;
2031 textFitMapSet["minSize"] = 10.f;
2032 textFitMapSet["maxSize"] = 100.f;
2033 textFitMapSet["stepSize"] = -1.f;
2034 textFitMapSet["fontSizeType"] = "pointSize";
2036 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2037 label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2039 application.GetScene().Add(label);
2041 application.SendNotification();
2042 application.Render();
2044 const Vector3 EXPECTED_NATURAL_SIZE(448.0f, 96.0f, 0.0f);
2045 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2047 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2048 DALI_TEST_CHECK(textFitChangedSignal);
2051 textFitMapSet.Clear();
2052 textFitMapSet["enable"] = true;
2053 textFitMapSet["minSize"] = ConvertPointToPixel(10.f);
2054 textFitMapSet["maxSize"] = ConvertPointToPixel(100.f);
2055 textFitMapSet["stepSize"] = ConvertPointToPixel(1.f);
2056 textFitMapSet["fontSizeType"] = "pixelSize";
2058 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2060 application.SendNotification();
2061 application.Render();
2063 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2068 int UtcDaliToolkitTextlabelTextFitStressTest(void)
2070 ToolkitTestApplication application;
2071 tet_infoline(" UtcDaliToolkitTextlabelTextFitStressTest");
2072 TextLabel label = TextLabel::New();
2073 Vector2 size(460.0f, 100.0f);
2074 label.SetProperty(Actor::Property::SIZE, size);
2075 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
2077 // connect to the text git changed signal.
2078 ConnectionTracker* testTracker = new ConnectionTracker();
2079 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2080 bool textFitChangedSignal = false;
2081 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2082 gTextFitChangedCallBackCalled = false;
2084 // check point size with veryvery big range
2085 Property::Map textFitMapSet;
2086 textFitMapSet["enable"] = true;
2087 textFitMapSet["minSize"] = 10.f;
2088 textFitMapSet["maxSize"] = 10000.f;
2089 textFitMapSet["stepSize"] = -1.0f;
2090 textFitMapSet["fontSizeType"] = "pointSize";
2092 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2093 label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2095 application.GetScene().Add(label);
2097 application.SendNotification();
2098 application.Render();
2100 const Vector3 EXPECTED_NATURAL_SIZE(448.0f, 96.0f, 0.0f);
2101 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2103 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2104 DALI_TEST_CHECK(textFitChangedSignal);
2109 int UtcDaliToolkitTextlabelFastTextFitStressTest(void)
2111 ToolkitTestApplication application;
2112 tet_infoline(" UtcDaliToolkitTextlabelFastTextFitStressTest");
2113 TextLabel label = TextLabel::New();
2114 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
2115 label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2117 // connect to the text git changed signal.
2118 ConnectionTracker* testTracker = new ConnectionTracker();
2119 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2120 bool textFitChangedSignal = false;
2121 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2122 gTextFitChangedCallBackCalled = false;
2124 application.GetScene().Add(label);
2126 // check text label width at range [100, 299]
2127 for(int i=100; i<300; i++)
2129 Vector2 size((float)i, 200.f);
2130 label.SetProperty(Actor::Property::SIZE, size);
2132 // check point size with veryvery big range
2133 Property::Map textFitMapSet;
2134 textFitMapSet["enable"] = true;
2135 textFitMapSet["minSize"] = 10.f;
2136 textFitMapSet["maxSize"] = 10000.f;
2137 textFitMapSet["stepSize"] = -1.0f;
2138 textFitMapSet["fontSizeType"] = "pointSize";
2140 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2142 application.SendNotification();
2143 application.Render();
2146 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2147 DALI_TEST_CHECK(textFitChangedSignal);
2152 int UtcDaliToolkitTextlabelTextFitMultiLine(void)
2154 ToolkitTestApplication application;
2155 tet_infoline(" UtcDaliToolkitTextlabelTextFitMultiLine");
2156 TextLabel label = TextLabel::New();
2157 Vector2 size(500.0f, 100.0f);
2158 label.SetProperty(Actor::Property::SIZE, size);
2159 label.SetProperty(TextLabel::Property::TEXT, "Hello world\nHello world");
2160 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2162 // connect to the text git changed signal.
2163 ConnectionTracker* testTracker = new ConnectionTracker();
2164 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2165 bool textFitChangedSignal = false;
2166 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2167 gTextFitChangedCallBackCalled = false;
2169 Property::Map textFitMapSet;
2170 textFitMapSet["enable"] = true;
2171 textFitMapSet["minSize"] = 10.f;
2172 textFitMapSet["maxSize"] = 100.f;
2173 textFitMapSet["stepSize"] = -1.0f;
2174 textFitMapSet["fontSizeType"] = "pointSize";
2176 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2177 label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2179 application.GetScene().Add(label);
2181 application.SendNotification();
2182 application.Render();
2184 float textFitFontSize = (label.GetProperty(Dali::Toolkit::DevelTextLabel::Property::TEXT_FIT).Get<Property::Map>())["fontSize"].Get<float>();
2185 DALI_TEST_EQUALS(textFitFontSize, 14.f, TEST_LOCATION);
2187 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2188 DALI_TEST_CHECK(textFitChangedSignal);
2193 int UtcDaliToolkitTextlabelTextFitArray(void)
2195 ToolkitTestApplication application;
2196 tet_infoline(" UtcDaliToolkitTextlabelTextFitArray");
2197 TextLabel label = TextLabel::New();
2198 Vector2 size(300.0f, 80.0f);
2199 label.SetProperty(Actor::Property::SIZE, size);
2200 label.SetProperty(TextLabel::Property::TEXT, "A Quick Brown Fox Jumps Over The Lazy Dog");
2201 label.SetProperty(DevelTextLabel::Property::MIN_LINE_SIZE, 80.f);
2202 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
2203 application.GetScene().Add(label);
2205 // make sorted options.
2206 std::vector<DevelTextLabel::FitOption> fitOptions;
2207 fitOptions.push_back(DevelTextLabel::FitOption(10, 12));
2208 fitOptions.push_back(DevelTextLabel::FitOption(8, 10));
2209 fitOptions.push_back(DevelTextLabel::FitOption(6, 8));
2210 fitOptions.push_back(DevelTextLabel::FitOption(4, 6));
2211 fitOptions.push_back(DevelTextLabel::FitOption(20, 22));
2212 fitOptions.push_back(DevelTextLabel::FitOption(22, 24));
2213 fitOptions.push_back(DevelTextLabel::FitOption(12, 14));
2215 DevelTextLabel::SetTextFitArray(label, true, fitOptions);
2217 application.SendNotification();
2218 application.Render();
2220 bool enable = Dali::Toolkit::DevelTextLabel::IsTextFitArrayEnabled(label);
2221 DALI_TEST_EQUALS(true, enable, TEST_LOCATION);
2223 std::vector<Dali::Toolkit::DevelTextLabel::FitOption> getFitOptions = Dali::Toolkit::DevelTextLabel::GetTextFitArray(label);
2224 size_t numberOfFitOptions = getFitOptions.size();
2225 DALI_TEST_EQUALS(7u, numberOfFitOptions, TEST_LOCATION);
2227 const Vector3 EXPECTED_NATURAL_SIZE(276.0f, 16.0f, 0.0f);
2228 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2230 std::vector<DevelTextLabel::FitOption> emptyFitOptions;
2231 DevelTextLabel::SetTextFitArray(label, false, emptyFitOptions);
2233 application.SendNotification();
2234 application.Render();
2236 enable = Dali::Toolkit::DevelTextLabel::IsTextFitArrayEnabled(label);
2237 DALI_TEST_EQUALS(false, enable, TEST_LOCATION);
2239 const Vector3 EXPECTED_NATURAL_SIZE_DISABLE(690.0f, 80.0f, 0.0f);
2240 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE_DISABLE, label.GetNaturalSize(), TEST_LOCATION);
2242 // make unsorted options.
2243 std::vector<DevelTextLabel::FitOption> unorderedFitOptions;
2244 unorderedFitOptions.push_back(DevelTextLabel::FitOption(4, 6));
2245 unorderedFitOptions.push_back(DevelTextLabel::FitOption(6, 8));
2246 unorderedFitOptions.push_back(DevelTextLabel::FitOption(8, 10));
2247 unorderedFitOptions.push_back(DevelTextLabel::FitOption(10, 8));
2249 DevelTextLabel::SetTextFitArray(label, true, unorderedFitOptions);
2251 application.SendNotification();
2252 application.Render();
2254 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2259 int UtcDaliToolkitTextlabelMaxTextureSet(void)
2261 ToolkitTestApplication application;
2262 tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
2264 DevelText::BitmapFontDescription fontDescription;
2265 fontDescription.name = "Digits";
2266 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f});
2268 TextAbstraction::BitmapFont bitmapFont;
2269 DevelText::CreateBitmapFont(fontDescription, bitmapFont);
2271 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2272 fontClient.GetFontId(bitmapFont);
2274 TextLabel label = TextLabel::New();
2275 label.SetProperty(TextLabel::Property::FONT_FAMILY, "Digits");
2276 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2277 label.SetProperty(TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded.");
2278 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2279 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2281 Property::Map underlineMapSet;
2282 underlineMapSet.Clear();
2283 underlineMapSet.Insert("enable", true);
2284 underlineMapSet.Insert("color", Color::RED);
2285 underlineMapSet.Insert("height", 1);
2286 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2287 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2289 Property::Map strikethroughMapSet;
2290 strikethroughMapSet.Clear();
2291 strikethroughMapSet.Insert("enable", true);
2292 strikethroughMapSet.Insert("color", Color::RED);
2293 strikethroughMapSet.Insert("height", 2.0f);
2294 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2295 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2297 application.GetScene().Add(label);
2299 application.SendNotification();
2300 application.Render();
2302 const int maxTextureSize = Dali::GetMaxTextureSize();
2303 // Whether the rendered text is greater than maxTextureSize
2304 DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2306 // Check if the number of renderers is greater than 1.
2307 DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2310 underlineMapSet.Clear();
2311 underlineMapSet.Insert("enable", false);
2312 underlineMapSet.Insert("color", Color::BLUE);
2313 underlineMapSet.Insert("height", 0);
2314 underlineMapSet.Insert("type", Text::Underline::DASHED);
2315 underlineMapSet.Insert("dashWidth", 2);
2316 underlineMapSet.Insert("dashGap", 1);
2317 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2318 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2320 application.GetScene().Add(label);
2322 application.SendNotification();
2323 application.Render();
2325 // Whether the rendered text is greater than maxTextureSize
2326 DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2328 // Check if the number of renderers is greater than 1.
2329 DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2332 underlineMapSet.Clear();
2333 underlineMapSet.Insert("enable", false);
2334 underlineMapSet.Insert("color", Color::BLUE);
2335 underlineMapSet.Insert("height", 0);
2336 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
2337 underlineMapSet.Insert("dashWidth", 2);
2338 underlineMapSet.Insert("dashGap", 1);
2339 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2340 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2342 application.GetScene().Add(label);
2344 application.SendNotification();
2345 application.Render();
2347 // Whether the rendered text is greater than maxTextureSize
2348 DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2350 // Check if the number of renderers is greater than 1.
2351 DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2353 // Coverage test for case of layoutSize is bigger than maxTextureSize
2354 float max_value = static_cast<float>(std::numeric_limits<uint16_t>::max());
2355 label.SetProperty(Actor::Property::SIZE, Vector2(max_value, 30.0f));
2356 application.SendNotification();
2357 application.Render();
2362 int UtcDaliToolkitTextlabelStrikethroughExceedsWidthAndHeight(void)
2364 ToolkitTestApplication application;
2365 tet_infoline(" UtcDaliToolkitTextlabelStrikethroughExceedsWidthAndHeight");
2367 TextLabel label = TextLabel::New();
2368 label.SetProperty(TextLabel::Property::TEXT, "Test");
2369 label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2370 //Exeeding BufferWidth
2371 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 400.0f));
2372 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2373 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2375 application.GetScene().Add(label);
2376 application.SendNotification();
2377 application.Render();
2379 Property::Map strikethroughMapSet;
2380 strikethroughMapSet.Clear();
2381 strikethroughMapSet.Insert("enable", true);
2382 strikethroughMapSet.Insert("color", Color::BLUE);
2383 strikethroughMapSet.Insert("height", 2.0f);
2384 label.SetProperty(TextLabel::Property::TEXT, "Test1");
2385 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2386 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2387 application.GetScene().Add(label);
2388 application.SendNotification();
2389 application.Render();
2390 // Check if the number of renderers is 1.
2391 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2393 label = TextLabel::New();
2394 label.SetProperty(TextLabel::Property::TEXT, "Test");
2395 label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2397 //Exeeding BufferHeight
2398 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.0f));
2399 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2400 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2402 application.GetScene().Add(label);
2403 application.SendNotification();
2404 application.Render();
2406 strikethroughMapSet.Clear();
2407 strikethroughMapSet.Insert("enable", true);
2408 strikethroughMapSet.Insert("color", Color::BLUE);
2409 strikethroughMapSet.Insert("height", 2.0f);
2410 label.SetProperty(TextLabel::Property::TEXT, "Test2");
2411 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2412 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2413 application.GetScene().Add(label);
2414 application.SendNotification();
2415 application.Render();
2416 // Check if the number of renderers is 1.
2417 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2422 int UtcDaliToolkitTextlabelUnderlineExceedsWidth(void)
2424 ToolkitTestApplication application;
2425 tet_infoline(" UtcDaliToolkitTextlabelUnderlineExceedsWidth");
2427 TextLabel label = TextLabel::New();
2428 label.SetProperty(TextLabel::Property::TEXT, "Test");
2429 label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2430 //Exeeding BufferWidth
2431 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 400.0f));
2432 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2433 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2435 application.GetScene().Add(label);
2436 application.SendNotification();
2437 application.Render();
2439 Property::Map underlineMapSet;
2442 underlineMapSet.Clear();
2443 underlineMapSet.Insert("enable", true);
2444 underlineMapSet.Insert("color", Color::BLUE);
2445 underlineMapSet.Insert("height", 1);
2446 underlineMapSet.Insert("type", Text::Underline::SOLID);
2447 underlineMapSet.Insert("dashWidth", 2);
2448 underlineMapSet.Insert("dashGap", 1);
2449 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2450 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2452 application.GetScene().Add(label);
2454 application.SendNotification();
2455 application.Render();
2457 // Check if the number of renderers is 1.
2458 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2461 underlineMapSet.Clear();
2462 underlineMapSet.Insert("enable", true);
2463 underlineMapSet.Insert("color", Color::BLUE);
2464 underlineMapSet.Insert("height", 1);
2465 underlineMapSet.Insert("type", Text::Underline::DASHED);
2466 underlineMapSet.Insert("dashWidth", 2);
2467 underlineMapSet.Insert("dashGap", 1);
2468 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2469 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2471 application.GetScene().Add(label);
2473 application.SendNotification();
2474 application.Render();
2476 // Check if the number of renderers is 1.
2477 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2480 underlineMapSet.Clear();
2481 underlineMapSet.Insert("enable", true);
2482 underlineMapSet.Insert("color", Color::BLUE);
2483 underlineMapSet.Insert("height", 1);
2484 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
2485 underlineMapSet.Insert("dashWidth", 2);
2486 underlineMapSet.Insert("dashGap", 1);
2487 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2488 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2490 application.GetScene().Add(label);
2492 application.SendNotification();
2493 application.Render();
2495 // Check if the number of renderers is 1.
2496 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2501 int UtcDaliToolkitTextlabelLastCharacterIndex(void)
2503 ToolkitTestApplication application;
2504 tet_infoline(" UtcDaliToolkitTextlabelLastCharacterIndex");
2506 Vector2 size(300.0f, 100.0f);
2508 Dali::Toolkit::DevelText::RendererParameters textParameters;
2509 textParameters.text = "This is a sample text to get the last index.";
2510 textParameters.layout = "multiLine";
2511 textParameters.fontSize = 20.f;
2512 textParameters.textWidth = 300u;
2513 textParameters.textHeight = 100u;
2514 textParameters.ellipsisEnabled = true;
2515 Dali::Property::Array indexArray = Dali::Toolkit::DevelText::GetLastCharacterIndex(textParameters);
2517 DALI_TEST_CHECK(!indexArray.Empty());
2518 DALI_TEST_EQUALS(indexArray.GetElementAt(0).Get<int>(), 10, TEST_LOCATION);
2523 int UtcDaliToolkitTextlabelFontSizeScale(void)
2525 ToolkitTestApplication application;
2526 tet_infoline(" UtcDaliToolkitTextlabelFontSizeScale");
2528 TextLabel label = TextLabel::New();
2529 label.SetProperty(TextLabel::Property::POINT_SIZE, 30.f);
2530 label.SetProperty(TextLabel::Property::TEXT, "Test");
2531 Vector3 nonScaledSize = label.GetNaturalSize();
2533 TextLabel labelScaled = TextLabel::New();
2534 labelScaled.SetProperty(TextLabel::Property::POINT_SIZE, 15.f);
2535 labelScaled.SetProperty(Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f);
2536 labelScaled.SetProperty(TextLabel::Property::TEXT, "Test");
2537 Vector3 scaledSize = labelScaled.GetNaturalSize();
2539 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
2541 label.SetProperty(TextLabel::Property::PIXEL_SIZE, 30.f);
2542 label.SetProperty(TextLabel::Property::TEXT, "Test");
2543 nonScaledSize = label.GetNaturalSize();
2545 labelScaled.SetProperty(TextLabel::Property::PIXEL_SIZE, 15.f);
2546 labelScaled.SetProperty(Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f);
2547 labelScaled.SetProperty(TextLabel::Property::TEXT, "Test");
2548 scaledSize = labelScaled.GetNaturalSize();
2550 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
2555 int UtcDaliToolkitTextlabelAnchorColor(void)
2557 ToolkitTestApplication application;
2558 tet_infoline(" UtcDaliToolkitTextlabelAnchorColor");
2559 TextLabel label = TextLabel::New();
2560 DALI_TEST_CHECK(label);
2562 application.GetScene().Add(label);
2564 // connect to the anchor clicked signal.
2565 ConnectionTracker* testTracker = new ConnectionTracker();
2566 DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
2567 bool anchorClickedSignal = false;
2568 label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
2570 gAnchorClickedCallBackCalled = false;
2571 label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
2572 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2573 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2574 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2575 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2577 // Check that anchor color can be properly set
2578 label.SetProperty(DevelTextLabel::Property::ANCHOR_COLOR, Color::BLUE);
2579 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_COLOR), Color::BLUE, TEST_LOCATION);
2581 label.SetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR, Color::RED);
2582 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR), Color::RED, TEST_LOCATION);
2584 application.SendNotification();
2585 application.Render();
2587 // Create a tap event to touch the text label.
2588 TestGenerateTap(application, 5.0f, 25.0f, 100);
2589 application.SendNotification();
2590 application.Render();
2592 // Update clicked color
2593 label.SetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR, Color::BLUE);
2594 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR), Color::BLUE, TEST_LOCATION);
2596 application.SendNotification();
2597 application.Render();
2599 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2600 DALI_TEST_CHECK(anchorClickedSignal);
2605 // Positive test for the anchorClicked signal.
2606 int UtcDaliToolkitTextlabelAnchorClicked(void)
2608 ToolkitTestApplication application;
2609 tet_infoline(" UtcDaliToolkitTextlabelAnchorClicked");
2610 TextLabel label = TextLabel::New();
2611 DALI_TEST_CHECK(label);
2613 application.GetScene().Add(label);
2615 // connect to the anchor clicked signal.
2616 ConnectionTracker* testTracker = new ConnectionTracker();
2617 DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
2618 bool anchorClickedSignal = false;
2619 label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
2621 gAnchorClickedCallBackCalled = false;
2622 label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
2623 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2624 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2625 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2626 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2628 application.SendNotification();
2629 application.Render();
2631 // Create a tap event to touch the text label.
2632 TestGenerateTap(application, 5.0f, 25.0f, 100);
2633 application.SendNotification();
2634 application.Render();
2636 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2637 DALI_TEST_CHECK(anchorClickedSignal);
2640 gAnchorClickedCallBackCalled = false;
2641 anchorClickedSignal = false;
2642 label.SetProperty(TextLabel::Property::TEXT, "");
2643 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, false);
2645 application.SendNotification();
2646 application.Render();
2649 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2650 label.SetProperty(TextLabel::Property::TEXT, "<a color='red' clicked-color='green' href='https://www.tizen.org'>TIZEN</a>");
2651 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2652 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2653 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2655 application.SendNotification();
2656 application.Render();
2658 // Create a tap event to touch the text label.
2659 TestGenerateTap(application, 5.0f, 25.0f, 200);
2660 application.SendNotification();
2661 application.Render();
2663 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2664 DALI_TEST_CHECK(anchorClickedSignal);
2666 gAnchorClickedCallBackNotCalled = true;
2667 // Tap the outside of anchor, callback should not be called.
2668 TestGenerateTap(application, 150.f, 100.f, 300);
2669 application.SendNotification();
2670 application.Render();
2672 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
2677 int UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize(void)
2679 ToolkitTestApplication application;
2680 tet_infoline(" UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize ");
2682 //TextLabel is not using Atlas but this is to unify font-size on text-controllers
2684 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
2685 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
2686 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
2688 // Create a text editor
2689 TextLabel textLabel = TextLabel::New();
2690 //Set size to avoid automatic eliding
2691 textLabel.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
2692 //Set very large font-size using point-size
2693 textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 1000);
2694 //Specify font-family
2695 textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2696 //Set text to check if appear or not
2697 textLabel.SetProperty(TextLabel::Property::TEXT, "A");
2699 application.GetScene().Add(textLabel);
2701 application.SendNotification();
2702 application.Render();
2703 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
2704 Vector3 naturalSize = textLabel.GetNaturalSize();
2706 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
2707 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
2712 int UtcDaliTextLabelHyphenWrapMode(void)
2714 ToolkitTestApplication application;
2715 tet_infoline(" UtcDaliTextLabelHyphenWrapMode ");
2718 TextLabel label = TextLabel::New();
2719 label.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
2720 label.SetProperty(TextLabel::Property::POINT_SIZE, 12.f);
2721 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2722 application.GetScene().Add(label);
2723 application.SendNotification();
2724 application.Render();
2726 label.SetProperty(TextLabel::Property::TEXT, "Hi Experimen");
2727 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
2728 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::HYPHENATION), TEST_LOCATION);
2730 application.SendNotification();
2731 application.Render();
2733 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2739 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
2741 label.SetProperty(TextLabel::Property::TEXT, "Hi Experimen");
2742 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
2743 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::MIXED), TEST_LOCATION);
2745 application.SendNotification();
2746 application.Render();
2748 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2755 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
2760 int utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged(void)
2762 ToolkitTestApplication application;
2764 tet_infoline(" utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged ");
2766 int lineCountBefore = 0;
2767 int lineCountAfter = 0;
2769 // Create a text editor
2770 TextLabel textLabel = TextLabel::New();
2771 //Set very large font-size using point-size
2772 textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 10);
2773 //Specify font-family
2774 textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2776 textLabel.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.f));
2777 //Set text longer than width of textLabel
2778 textLabel.SetProperty(TextLabel::Property::TEXT, "Short text");
2779 //Set line wrap mode Character
2780 textLabel.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
2781 textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
2783 application.GetScene().Add(textLabel);
2785 application.SendNotification();
2786 application.Render();
2788 lineCountBefore = textLabel.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2790 textLabel.SetProperty(TextLabel::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
2791 lineCountAfter = textLabel.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2793 // When the text changed, the Line-count should be updated according to new text.
2794 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
2795 DALI_TEST_EQUALS(lineCountBefore, 1, TEST_LOCATION);
2796 DALI_TEST_GREATER(lineCountAfter, 1, TEST_LOCATION);
2801 int utcDaliTextLabelGeometryRTL(void)
2803 ToolkitTestApplication application;
2804 tet_infoline(" utcDaliTextLabelGeometryRTL");
2806 TextLabel label = TextLabel::New();
2807 DALI_TEST_CHECK(label);
2809 application.GetScene().Add(label);
2811 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2812 label.SetProperty(Actor::Property::SIZE, Vector2(150.f, 100.f));
2813 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2814 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2815 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2816 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2817 label.SetProperty(TextLabel::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر");
2818 // Avoid a crash when core load gl resources.
2819 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2821 // Render and notify
2822 application.SendNotification();
2823 application.Render();
2825 unsigned int expectedCount = 4;
2826 unsigned int startIndex = 3;
2827 unsigned int endIndex = 24;
2829 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2830 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2832 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2833 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2835 Vector<Vector2> expectedSizes;
2836 Vector<Vector2> expectedPositions;
2838 expectedPositions.PushBack(Vector2(25, 0));
2839 expectedSizes.PushBack(Vector2(34, 25));
2841 expectedPositions.PushBack(Vector2(-1, 25));
2842 expectedSizes.PushBack(Vector2(53, 25));
2844 expectedPositions.PushBack(Vector2(-1, 50));
2845 expectedSizes.PushBack(Vector2(60, 25));
2847 expectedPositions.PushBack(Vector2(75, 75));
2848 expectedSizes.PushBack(Vector2(37, 25));
2850 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2855 int utcDaliTextLabelGeometryGlyphMiddle(void)
2857 ToolkitTestApplication application;
2858 tet_infoline(" utcDaliTextLabelGeometryGlyphMiddle");
2860 TextLabel label = TextLabel::New();
2861 DALI_TEST_CHECK(label);
2863 application.GetScene().Add(label);
2865 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2866 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2867 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2868 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2869 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2870 label.SetProperty(TextLabel::Property::TEXT, "لا تحتوي على لا");
2872 // Avoid a crash when core load gl resources.
2873 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2875 // Render and notify
2876 application.SendNotification();
2877 application.Render();
2879 unsigned int expectedCount = 1;
2880 unsigned int startIndex = 1;
2881 unsigned int endIndex = 13;
2883 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2884 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2886 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2887 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2889 Vector<Vector2> expectedSizes;
2890 Vector<Vector2> expectedPositions;
2892 expectedPositions.PushBack(Vector2(6, 0));
2893 expectedSizes.PushBack(Vector2(125, 25));
2895 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2900 int utcDaliTextLabelGeometryOneGlyph(void)
2902 ToolkitTestApplication application;
2903 tet_infoline(" utcDaliTextLabelGeometryOneGlyph ");
2905 TextLabel label = TextLabel::New();
2906 DALI_TEST_CHECK(label);
2908 application.GetScene().Add(label);
2910 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2911 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2912 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2913 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2914 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2915 label.SetProperty(TextLabel::Property::TEXT, "H");
2917 // Avoid a crash when core load gl resources.
2918 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2920 // Render and notify
2921 application.SendNotification();
2922 application.Render();
2924 unsigned int expectedCount = 1;
2925 unsigned int startIndex = 0;
2926 unsigned int endIndex = 0;
2928 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2929 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2931 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2932 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2934 Vector<Vector2> expectedSizes;
2935 Vector<Vector2> expectedPositions;
2937 expectedPositions.PushBack(Vector2(-2, 0));
2938 expectedSizes.PushBack(Vector2(16, 25));
2940 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2942 positionsList.Clear();
2948 positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2949 sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2951 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2956 int utcDaliTextLabelGeometryNullPtr(void)
2958 ToolkitTestApplication application;
2959 tet_infoline("utcDaliTextLabelGeometryNullPtr");
2961 TextLabel label = TextLabel::New();
2962 DALI_TEST_CHECK(label);
2964 application.GetScene().Add(label);
2966 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2967 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2968 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2969 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2970 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2971 label.SetProperty(TextLabel::Property::TEXT, "");
2973 // Avoid a crash when core load gl resources.
2974 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2976 unsigned int expectedCount = 0;
2977 unsigned int startIndex = 0;
2978 unsigned int endIndex = 0;
2980 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2981 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2983 // Render and notify
2984 application.SendNotification();
2985 application.Render();
2987 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2988 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2993 int UtcDaliToolkitTextlabelEllipsisPositionProperty(void)
2995 ToolkitTestApplication application;
2996 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty ");
2997 TextLabel textLabel = TextLabel::New();
2999 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Default is END");
3000 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3002 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START");
3003 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
3004 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3006 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE");
3007 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
3008 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3010 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END");
3011 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
3012 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3014 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using integer");
3015 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 1);
3016 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3018 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using integer");
3019 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 2);
3020 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3022 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using integer");
3023 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 0);
3024 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3026 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
3027 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "START");
3028 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3030 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
3031 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "MIDDLE");
3032 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3034 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
3035 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "END");
3036 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3038 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
3039 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "start");
3040 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3042 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
3043 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "middle");
3044 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3046 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
3047 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "end");
3048 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3053 int UtcDaliToolkitTextLabelStrikethroughGeneration(void)
3055 ToolkitTestApplication application;
3056 tet_infoline(" UtcDaliToolkitTextLabelStrikethroughGeneration");
3058 TextLabel textLabel = TextLabel::New();
3059 textLabel.SetProperty(TextLabel::Property::TEXT, "Test");
3060 textLabel.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
3061 textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3062 textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
3064 application.GetScene().Add(textLabel);
3065 application.SendNotification();
3066 application.Render();
3068 Property::Map strikethroughMapSet;
3069 Property::Map strikethroughMapGet;
3071 strikethroughMapSet.Insert("enable", true);
3072 strikethroughMapSet.Insert("color", Color::RED);
3073 strikethroughMapSet.Insert("height", 2.0f);
3075 // Check the strikethrough property
3076 textLabel.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
3077 strikethroughMapGet = textLabel.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
3078 textLabel.SetProperty(TextLabel::Property::TEXT, "Test1");
3079 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
3080 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
3082 // Render and notify
3083 application.SendNotification();
3084 application.Render();
3086 strikethroughMapSet.Clear();
3087 strikethroughMapGet.Clear();
3092 int UtcDaliToolkitTextLabelMarkupRelativeLineHeight(void)
3094 ToolkitTestApplication application;
3095 tet_infoline(" UtcDaliToolkitTextLabelMarkupRelativeLineHeight");
3097 TextLabel label = TextLabel::New();
3098 label.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3099 label.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3100 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3101 label.SetProperty(TextLabel::Property::TEXT, "line 1\nline 2\nline 3\nline 4\nline 5");
3102 label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3103 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
3104 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3106 TextLabel labelSingleLineParagraph = TextLabel::New();
3107 labelSingleLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3108 labelSingleLineParagraph.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3109 labelSingleLineParagraph.SetProperty(TextLabel::Property::MULTI_LINE, true);
3110 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");
3111 labelSingleLineParagraph.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3112 labelSingleLineParagraph.SetProperty(TextLabel::Property::ELLIPSIS, false);
3113 labelSingleLineParagraph.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3115 TextLabel labelMultiLineParagraph = TextLabel::New();
3116 labelMultiLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3117 labelMultiLineParagraph.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3118 labelMultiLineParagraph.SetProperty(TextLabel::Property::MULTI_LINE, true);
3119 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");
3120 labelMultiLineParagraph.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3121 labelMultiLineParagraph.SetProperty(TextLabel::Property::ELLIPSIS, false);
3122 labelMultiLineParagraph.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3124 application.GetScene().Add(label);
3125 application.GetScene().Add(labelSingleLineParagraph);
3126 application.GetScene().Add(labelMultiLineParagraph);
3127 application.SendNotification();
3128 application.Render();
3130 Vector3 naturalSize = label.GetNaturalSize();
3131 Vector3 relativeSingleNaturalSize = labelSingleLineParagraph.GetNaturalSize();
3132 Vector3 relativeMultiNaturalSize = labelMultiLineParagraph.GetNaturalSize();
3134 float lineSize = naturalSize.y / 5.0f; //total size/number of lines
3136 //no effect of relative line size for paragraph with single line
3137 DALI_TEST_EQUALS(naturalSize.y, relativeSingleNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3139 DALI_TEST_EQUALS(lineSize * 8.5f, relativeMultiNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3144 int UtcDaliToolkitTextLabelRelativeLineHeight(void)
3146 ToolkitTestApplication application;
3147 tet_infoline(" UtcDaliToolkitTextLabelRelativeLineHeight");
3149 TextLabel label = TextLabel::New();
3150 label.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3151 label.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3152 label.SetProperty(TextLabel::Property::TEXT, "Hello\nWorld");
3154 application.GetScene().Add(label);
3155 application.SendNotification();
3156 application.Render();
3158 Vector3 naturalSize = label.GetNaturalSize();
3160 label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 0.5f);
3162 application.SendNotification();
3163 application.Render();
3165 Vector3 relativeNaturalSize = label.GetNaturalSize();
3167 DALI_TEST_EQUALS(naturalSize.y, relativeNaturalSize.y, TEST_LOCATION);
3169 label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 2.0f);
3171 application.SendNotification();
3172 application.Render();
3174 relativeNaturalSize = label.GetNaturalSize();
3176 DALI_TEST_EQUALS(naturalSize.y * 2, relativeNaturalSize.y, TEST_LOCATION);
3180 int UtcDaliTextLabelCharacterSpacing(void)
3182 ToolkitTestApplication application;
3183 tet_infoline(" UtcDaliTextLabelCharacterSpacing ");
3185 TextLabel textLabel = TextLabel::New();
3187 textLabel.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
3189 application.GetScene().Add(textLabel);
3190 application.SendNotification();
3191 application.Render();
3193 textLabel.SetProperty(TextLabel::Property::TEXT, "Hi Experiment");
3194 textLabel.SetProperty(DevelTextLabel::Property::CHARACTER_SPACING, 10.f);
3195 DALI_TEST_EQUALS(textLabel.GetProperty<float>(DevelTextLabel::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3197 application.SendNotification();
3198 application.Render();
3203 int UtcDaliTextTextLabelSizeNegativeLineSpacing(void)
3205 ToolkitTestApplication application;
3206 tet_infoline("UtcDaliTextTextLabelSizeNegativeLineSpacing");
3208 TextLabel label = TextLabel::New();
3210 float lineSpacing = -20.f;
3212 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
3213 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
3214 label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
3215 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3216 label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
3218 application.GetScene().Add(label);
3219 application.SendNotification();
3220 application.Render();
3222 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, 0, 123);
3223 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, 0, 123);
3225 Vector2 lastLinePos = positionsList[positionsList.Size() - 1];
3226 Vector2 lastLineSize = sizeList[sizeList.Size() - 1];
3228 DALI_TEST_EQUALS(sizeList[0].y * (sizeList.Size() - 1), lastLinePos.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3229 DALI_TEST_EQUALS(sizeList[0].y - lineSpacing, lastLineSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3231 application.SendNotification();
3232 application.Render();
3237 int UtcDaliTextLabelNegativeLineSpacingWithEllipsis(void)
3239 ToolkitTestApplication application;
3240 tet_infoline("UtcDaliTextLabelNegativeLineSpacingWithEllipsis");
3242 TextLabel label = TextLabel::New();
3244 float lineSpacing = -20.f;
3246 label.SetProperty(Actor::Property::SIZE, Vector2(480.0f, 100.f));
3247 label.SetProperty(TextLabel::Property::POINT_SIZE, 11.0f);
3248 label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
3249 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3250 label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
3251 label.SetProperty(TextLabel::Property::ELLIPSIS, true);
3253 application.GetScene().Add(label);
3254 application.SendNotification();
3255 application.Render();
3257 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, 0, 123);
3259 int lineCount = sizeList.Size();
3260 DALI_TEST_EQUALS(4, lineCount, TEST_LOCATION);
3262 application.SendNotification();
3263 application.Render();
3268 int UtcDaliToolkitTextlabelParagraphTag(void)
3270 ToolkitTestApplication application;
3271 tet_infoline(" UtcDaliToolkitTextlabelParagraphTag");
3272 TextLabel labelNewlineSeparator = TextLabel::New();
3273 TextLabel labelParagraphTag = TextLabel::New();
3274 DALI_TEST_CHECK(labelNewlineSeparator);
3275 DALI_TEST_CHECK(labelParagraphTag);
3277 application.GetScene().Add(labelNewlineSeparator);
3278 application.GetScene().Add(labelParagraphTag);
3280 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
3281 labelNewlineSeparator.SetProperty(TextLabel::Property::MULTI_LINE, true);
3282 labelNewlineSeparator.SetProperty(TextLabel::Property::ELLIPSIS, false);
3283 labelNewlineSeparator.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3284 labelNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3285 labelNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3286 labelNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3287 labelNewlineSeparator.SetProperty(TextLabel::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
3289 labelParagraphTag.SetProperty(TextLabel::Property::MULTI_LINE, true);
3290 labelParagraphTag.SetProperty(TextLabel::Property::ELLIPSIS, false);
3291 labelParagraphTag.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3292 labelParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3293 labelParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3294 labelParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3295 labelParagraphTag.SetProperty(TextLabel::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
3297 application.SendNotification();
3298 application.Render();
3300 Vector3 textNaturalSizeNewlineSeparator = labelNewlineSeparator.GetNaturalSize();
3301 Vector3 textNaturalSizeParagraphTag = labelParagraphTag.GetNaturalSize();
3303 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
3305 application.SendNotification();
3306 application.Render();
3311 int utcDaliTextLabelGetTextBoundingRectangle(void)
3313 ToolkitTestApplication application;
3314 tet_infoline(" utcDaliTextLabelGeometryEllipsisMiddle");
3316 TextLabel label = TextLabel::New();
3317 DALI_TEST_CHECK(label);
3319 application.GetScene().Add(label);
3321 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
3322 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3323 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3324 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3325 label.SetProperty(TextLabel::Property::TEXT, "Hello this is the Text Bounding Rectangle TC");
3327 // Avoid a crash when core load gl resources.
3328 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3330 // Render and notify
3331 application.SendNotification();
3332 application.Render();
3334 unsigned int startIndex = 0;
3335 unsigned int endIndex = 15;
3337 Rect<> textBoundingRectangle = DevelTextLabel::GetTextBoundingRectangle(label, startIndex, endIndex);
3338 Rect<> expectedTextBoundingRectangle = {0, 0, 100, 25};
3340 TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);
3345 int utcDaliTextLabelRemoveFrontInset(void)
3347 ToolkitTestApplication application;
3348 tet_infoline(" utcDaliTextLabelRemoveFrontInset");
3350 TextLabel label = TextLabel::New();
3351 DALI_TEST_CHECK(label);
3353 application.GetScene().Add(label);
3354 application.SendNotification();
3355 application.Render();
3357 DevelTextLabel::SetRemoveFrontInset(label, false);
3358 DALI_TEST_CHECK(!DevelTextLabel::IsRemoveFrontInset(label));
3363 int utcDaliTextLabelRemoveBackInset(void)
3365 ToolkitTestApplication application;
3366 tet_infoline(" utcDaliTextLabelRemoveBackInset");
3368 TextLabel label = TextLabel::New();
3369 DALI_TEST_CHECK(label);
3371 application.GetScene().Add(label);
3372 application.SendNotification();
3373 application.Render();
3375 DevelTextLabel::SetRemoveBackInset(label, false);
3376 DALI_TEST_CHECK(!DevelTextLabel::IsRemoveBackInset(label));