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";
81 const std::string DEFAULT_FONT_DIR("/resources/fonts");
82 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
84 static bool gAnchorClickedCallBackCalled;
85 static bool gAnchorClickedCallBackNotCalled;
87 static bool gTextFitChangedCallBackCalled;
89 struct CallbackFunctor
91 CallbackFunctor(bool* callbackFlag)
92 : mCallbackFlag(callbackFlag)
98 *mCallbackFlag = true;
103 static void TestAnchorClickedCallback(TextLabel control, const char* href, unsigned int hrefLength)
105 tet_infoline(" TestAnchorClickedCallback");
107 gAnchorClickedCallBackNotCalled = false;
109 if(!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
111 gAnchorClickedCallBackCalled = true;
115 static void TestTextFitChangedCallback(TextLabel control)
117 tet_infoline(" TestTextFitChangedCallback");
118 gTextFitChangedCallBackCalled = true;
121 bool DaliTestCheckMaps(const Property::Map& mapGet, const Property::Map& mapSet, const std::vector<std::string>& indexConversionTable = std::vector<std::string>())
123 const Property::Map::SizeType size = mapGet.Count();
125 if(size == mapSet.Count())
127 for(unsigned int index = 0u; index < size; ++index)
129 const KeyValuePair& valueGet = mapGet.GetKeyValue(index);
131 // Find the keys of the 'get' map
132 Property::Index indexKey = valueGet.first.indexKey;
133 std::string stringKey = valueGet.first.stringKey;
135 if(!indexConversionTable.empty())
137 if(stringKey.empty())
139 stringKey = indexConversionTable[indexKey];
142 if((indexKey == Property::INVALID_INDEX) && !stringKey.empty())
144 Property::Index index = 0u;
145 for(auto key : indexConversionTable)
157 const Property::Value* const valueSet = mapSet.Find(indexKey, stringKey);
159 if(nullptr != valueSet)
161 if((valueSet->GetType() == Dali::Property::STRING) && (valueGet.second.Get<std::string>() != valueSet->Get<std::string>()))
163 tet_printf("Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str());
166 else if((valueSet->GetType() == Dali::Property::BOOLEAN) && (valueGet.second.Get<bool>() != valueSet->Get<bool>()))
168 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>());
171 else if((valueSet->GetType() == Dali::Property::INTEGER) && (valueGet.second.Get<int>() != valueSet->Get<int>()))
173 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>());
176 else if((valueSet->GetType() == Dali::Property::FLOAT) && (valueGet.second.Get<float>() != valueSet->Get<float>()))
178 tet_printf("Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>());
181 else if((valueSet->GetType() == Dali::Property::VECTOR2) && (valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>()))
183 Vector2 vector2Get = valueGet.second.Get<Vector2>();
184 Vector2 vector2Set = valueSet->Get<Vector2>();
185 tet_printf("Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y);
188 else if((valueSet->GetType() == Dali::Property::VECTOR4) && (valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>()))
190 Vector4 vector4Get = valueGet.second.Get<Vector4>();
191 Vector4 vector4Set = valueSet->Get<Vector4>();
192 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);
198 if(valueGet.first.type == Property::Key::INDEX)
200 tet_printf(" The key %d doesn't exist.", valueGet.first.indexKey);
204 tet_printf(" The key %s doesn't exist.", valueGet.first.stringKey.c_str());
216 int UtcDaliToolkitTextLabelConstructorP(void)
218 ToolkitTestApplication application;
219 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
221 DALI_TEST_CHECK(!textLabel);
225 int UtcDaliToolkitTextLabelNewP(void)
227 ToolkitTestApplication application;
228 tet_infoline(" UtcDaliToolkitTextLabelNewP");
229 TextLabel textLabel = TextLabel::New("Test Text");
230 DALI_TEST_CHECK(textLabel);
234 int UtcDaliToolkitTextLabelDownCastP(void)
236 ToolkitTestApplication application;
237 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
238 TextLabel textLabel1 = TextLabel::New();
239 BaseHandle object(textLabel1);
241 TextLabel textLabel2 = TextLabel::DownCast(object);
242 DALI_TEST_CHECK(textLabel2);
244 TextLabel textLabel3 = DownCast<TextLabel>(object);
245 DALI_TEST_CHECK(textLabel3);
249 int UtcDaliToolkitTextLabelDownCastN(void)
251 ToolkitTestApplication application;
252 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
253 BaseHandle uninitializedObject;
254 TextLabel textLabel1 = TextLabel::DownCast(uninitializedObject);
255 DALI_TEST_CHECK(!textLabel1);
257 TextLabel textLabel2 = DownCast<TextLabel>(uninitializedObject);
258 DALI_TEST_CHECK(!textLabel2);
262 int UtcDaliToolkitTextLabelCopyConstructorP(void)
264 ToolkitTestApplication application;
265 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
266 TextLabel textLabel = TextLabel::New();
267 textLabel.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
269 TextLabel copy(textLabel);
270 DALI_TEST_CHECK(copy);
271 DALI_TEST_CHECK(copy.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR) == textLabel.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR));
275 int UtcDaliTextLabelMoveConstructor(void)
277 ToolkitTestApplication application;
279 TextLabel textLabel = TextLabel::New();
280 textLabel.SetProperty(TextLabel::Property::TEXT, "Test");
281 DALI_TEST_CHECK(textLabel.GetProperty<std::string>(TextLabel::Property::TEXT) == "Test");
283 TextLabel moved = std::move(textLabel);
284 DALI_TEST_CHECK(moved);
285 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
286 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextLabel::Property::TEXT) == "Test");
287 DALI_TEST_CHECK(!textLabel);
292 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
294 ToolkitTestApplication application;
295 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
296 TextLabel textLabel = TextLabel::New();
297 textLabel.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
299 TextLabel copy = textLabel;
300 DALI_TEST_CHECK(copy);
301 DALI_TEST_CHECK(copy.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR) == textLabel.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR));
305 int UtcDaliTextLabelMoveAssignment(void)
307 ToolkitTestApplication application;
309 TextLabel textLabel = TextLabel::New();
310 textLabel.SetProperty(TextLabel::Property::TEXT, "Test");
311 DALI_TEST_CHECK(textLabel.GetProperty<std::string>(TextLabel::Property::TEXT) == "Test");
314 moved = std::move(textLabel);
315 DALI_TEST_CHECK(moved);
316 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
317 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextLabel::Property::TEXT) == "Test");
318 DALI_TEST_CHECK(!textLabel);
323 // Positive test case for a method
324 int UtcDaliToolkitTextLabelGetPropertyP(void)
326 ToolkitTestApplication application;
327 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
328 TextLabel label = TextLabel::New("Test Text");
329 DALI_TEST_CHECK(label);
331 // Check Property Indices are correct
332 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_RENDERING_BACKEND) == DevelTextLabel::Property::RENDERING_BACKEND);
333 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_TEXT) == TextLabel::Property::TEXT);
334 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_FONT_FAMILY) == TextLabel::Property::FONT_FAMILY);
335 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_FONT_STYLE) == TextLabel::Property::FONT_STYLE);
336 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_POINT_SIZE) == TextLabel::Property::POINT_SIZE);
337 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_MULTI_LINE) == TextLabel::Property::MULTI_LINE);
338 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_HORIZONTAL_ALIGNMENT) == TextLabel::Property::HORIZONTAL_ALIGNMENT);
339 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_VERTICAL_ALIGNMENT) == TextLabel::Property::VERTICAL_ALIGNMENT);
340 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_TEXT_COLOR) == TextLabel::Property::TEXT_COLOR);
341 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP);
342 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_AUTO_SCROLL) == TextLabel::Property::ENABLE_AUTO_SCROLL);
343 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED) == TextLabel::Property::AUTO_SCROLL_SPEED);
344 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT);
345 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP) == TextLabel::Property::AUTO_SCROLL_GAP);
346 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_LINE_SPACING) == TextLabel::Property::LINE_SPACING);
347 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_UNDERLINE) == TextLabel::Property::UNDERLINE);
348 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_SHADOW) == TextLabel::Property::SHADOW);
349 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_EMBOSS) == TextLabel::Property::EMBOSS);
350 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_OUTLINE) == TextLabel::Property::OUTLINE);
351 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_BACKGROUND) == DevelTextLabel::Property::BACKGROUND);
352 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_PIXEL_SIZE) == TextLabel::Property::PIXEL_SIZE);
353 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ELLIPSIS) == TextLabel::Property::ELLIPSIS);
354 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY);
355 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_FONT_SIZE_SCALE) == DevelTextLabel::Property::FONT_SIZE_SCALE);
356 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE);
357 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ELLIPSIS_POSITION) == DevelTextLabel::Property::ELLIPSIS_POSITION);
358 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextLabel::Property::STRIKETHROUGH);
363 int UtcDaliToolkitTextLabelSetPropertyP(void)
365 ToolkitTestApplication application;
366 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
367 TextLabel label = TextLabel::New();
368 DALI_TEST_CHECK(label);
370 application.GetScene().Add(label);
372 // Note - we can't check the defaults since the stylesheets are platform-specific
373 label.SetProperty(DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
374 DALI_TEST_EQUALS((DevelText::RenderingType)label.GetProperty<int>(DevelTextLabel::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
376 // Check that text can be correctly reset
377 label.SetProperty(TextLabel::Property::TEXT, "Setting Text");
378 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
380 // Check font properties.
381 label.SetProperty(TextLabel::Property::FONT_FAMILY, "Setting font family");
382 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
384 Property::Map fontStyleMapSet;
385 Property::Map fontStyleMapGet;
387 fontStyleMapSet.Insert("weight", "bold");
388 fontStyleMapSet.Insert("width", "condensed");
389 fontStyleMapSet.Insert("slant", "italic");
390 label.SetProperty(TextLabel::Property::FONT_STYLE, fontStyleMapSet);
392 fontStyleMapGet = label.GetProperty<Property::Map>(TextLabel::Property::FONT_STYLE);
393 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
394 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
396 // Check the old font style format.
397 fontStyleMapSet.Clear();
398 fontStyleMapSet.Insert("weight", "thin");
399 fontStyleMapSet.Insert("width", "expanded");
400 fontStyleMapSet.Insert("slant", "oblique");
401 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
403 label.SetProperty(TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}");
404 std::string getFontStyle = label.GetProperty<std::string>(TextLabel::Property::FONT_STYLE);
405 DALI_TEST_EQUALS(getFontStyle, strFontStyle, TEST_LOCATION);
407 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
408 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
410 label.SetProperty(DevelTextLabel::Property::FONT_SIZE_SCALE, 2.5f);
411 DALI_TEST_EQUALS(label.GetProperty<float>(DevelTextLabel::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
412 label.SetProperty(DevelTextLabel::Property::FONT_SIZE_SCALE, 1.0f);
414 label.SetProperty(DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE, false);
415 DALI_TEST_EQUALS(label.GetProperty<bool>(DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
416 label.SetProperty(DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE, true);
419 fontStyleMapSet.Clear();
420 fontStyleMapSet.Insert("weight", "normal");
421 fontStyleMapSet.Insert("slant", "oblique");
423 label.SetProperty(TextLabel::Property::FONT_STYLE, fontStyleMapSet);
424 fontStyleMapGet = label.GetProperty<Property::Map>(TextLabel::Property::FONT_STYLE);
425 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
426 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
428 fontStyleMapSet.Clear();
429 fontStyleMapSet.Insert("slant", "roman");
431 label.SetProperty(TextLabel::Property::FONT_STYLE, fontStyleMapSet);
432 fontStyleMapGet = label.GetProperty<Property::Map>(TextLabel::Property::FONT_STYLE);
433 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
435 // Replace 'roman' for 'normal'.
436 Property::Value* slantValue = fontStyleMapGet.Find("slant");
437 if(NULL != slantValue)
439 if("normal" == slantValue->Get<std::string>())
441 fontStyleMapGet["slant"] = "roman";
444 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
446 fontStyleMapSet.Clear();
448 label.SetProperty(TextLabel::Property::FONT_STYLE, fontStyleMapSet);
449 fontStyleMapGet = label.GetProperty<Property::Map>(TextLabel::Property::FONT_STYLE);
450 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
451 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
454 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
455 DALI_TEST_EQUALS(label.GetProperty<bool>(TextLabel::Property::MULTI_LINE), true, TEST_LOCATION);
457 // Check that the Alignment properties can be correctly set
458 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
459 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::HORIZONTAL_ALIGNMENT), "CENTER", TEST_LOCATION);
460 label.SetProperty(TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
461 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
463 // Check that text color can be properly set
464 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLUE);
465 DALI_TEST_EQUALS(label.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR), Color::BLUE, TEST_LOCATION);
467 Property::Map strikethroughMapSet;
468 Property::Map strikethroughMapGet;
470 strikethroughMapSet.Insert("enable", false);
471 strikethroughMapSet.Insert("color", Color::BLUE);
472 strikethroughMapSet.Insert("height", 2.0f);
474 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
476 strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
477 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
478 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
480 Property::Map underlineMapSet;
481 Property::Map underlineMapGet;
483 underlineMapSet.Insert("enable", false);
484 underlineMapSet.Insert("color", Color::BLUE);
485 underlineMapSet.Insert("height", 0);
486 underlineMapSet.Insert("type", Text::Underline::SOLID);
487 underlineMapSet.Insert("dashWidth", 2);
488 underlineMapSet.Insert("dashGap", 1);
490 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
492 application.SendNotification();
493 application.Render();
495 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
496 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
497 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
500 underlineMapSet.Clear();
501 underlineMapGet.Clear();
503 underlineMapSet.Insert("enable", false);
504 underlineMapSet.Insert("color", Color::BLUE);
505 underlineMapSet.Insert("height", 0);
506 underlineMapSet.Insert("type", Text::Underline::DASHED);
507 underlineMapSet.Insert("dashWidth", 2);
508 underlineMapSet.Insert("dashGap", 1);
510 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
512 application.SendNotification();
513 application.Render();
515 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
516 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
517 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
520 underlineMapSet.Clear();
521 underlineMapGet.Clear();
523 underlineMapSet.Insert("enable", false);
524 underlineMapSet.Insert("color", Color::BLUE);
525 underlineMapSet.Insert("height", 0);
526 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
527 underlineMapSet.Insert("dashWidth", 2);
528 underlineMapSet.Insert("dashGap", 1);
530 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
532 application.SendNotification();
533 application.Render();
535 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
536 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
537 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
539 TextLabel label2 = TextLabel::New("New text");
540 DALI_TEST_CHECK(label2);
541 DALI_TEST_EQUALS(label2.GetProperty<std::string>(TextLabel::Property::TEXT), std::string("New text"), TEST_LOCATION);
543 // Check the enable markup property.
544 DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ENABLE_MARKUP));
545 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
546 DALI_TEST_CHECK(label.GetProperty<bool>(TextLabel::Property::ENABLE_MARKUP));
548 // Check the text property when markup is enabled
549 label.SetProperty(TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>");
550 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::TEXT), std::string("MarkupText"), TEST_LOCATION);
552 // Check for incomplete marks.
553 label.SetProperty(TextLabel::Property::TEXT, "<color='white'><i>Markup</i><b>Text</b></color>");
554 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::TEXT), std::string("MarkupText"), TEST_LOCATION);
557 application.SendNotification();
558 application.Render();
562 tet_result(TET_FAIL);
565 // Check autoscroll properties
566 const int SCROLL_SPEED = 80;
567 const int SCROLL_LOOPS = 4;
568 const float SCROLL_GAP = 50.0f;
569 const float SCROLL_LOOP_DELAY = 0.3f;
570 const std::string STOP_IMMEDIATE = std::string("IMMEDIATE");
571 const std::string STOP_FINISH_LOOP = std::string("FINISH_LOOP");
573 label.SetProperty(TextLabel::Property::MULTI_LINE, false); // Autoscroll only supported in single line
574 DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ENABLE_AUTO_SCROLL));
575 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
576 DALI_TEST_CHECK(label.GetProperty<bool>(TextLabel::Property::ENABLE_AUTO_SCROLL));
577 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED);
578 DALI_TEST_EQUALS(SCROLL_SPEED, label.GetProperty<int>(TextLabel::Property::AUTO_SCROLL_SPEED), TEST_LOCATION);
579 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS);
580 DALI_TEST_EQUALS(SCROLL_LOOPS, label.GetProperty<int>(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT), TEST_LOCATION);
581 label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP);
582 DALI_TEST_EQUALS(SCROLL_GAP, label.GetProperty<float>(TextLabel::Property::AUTO_SCROLL_GAP), TEST_LOCATION);
583 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY);
584 DALI_TEST_EQUALS(SCROLL_LOOP_DELAY, label.GetProperty<float>(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY), TEST_LOCATION);
586 //Check autoscroll stop type property
587 label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
588 DALI_TEST_EQUALS(STOP_IMMEDIATE, label.GetProperty<std::string>(TextLabel::Property::AUTO_SCROLL_STOP_MODE), TEST_LOCATION);
590 label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
591 DALI_TEST_EQUALS(STOP_FINISH_LOOP, label.GetProperty<std::string>(TextLabel::Property::AUTO_SCROLL_STOP_MODE), TEST_LOCATION);
593 // test natural size with multi-line and line spacing
595 TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
596 Vector3 oneLineNaturalSize = label3.GetNaturalSize();
597 label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
598 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
599 Vector3 multiLineNaturalSize = label3.GetNaturalSize();
601 // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
602 // The height of the text when multi-line is enabled will be larger
603 DALI_TEST_CHECK(oneLineNaturalSize.width > multiLineNaturalSize.width);
604 DALI_TEST_CHECK(oneLineNaturalSize.height < multiLineNaturalSize.height);
606 // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
607 // Everything else will remain the same
608 int lineSpacing = 20;
609 label3.SetProperty(TextLabel::Property::LINE_SPACING, lineSpacing);
610 Vector3 expectedAfterLineSpacingApplied(multiLineNaturalSize);
611 expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
612 DALI_TEST_EQUALS(expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION);
615 // single line, line spacing must not affect natural size of the text, only add the spacing to the height
617 TextLabel label3 = TextLabel::New("Some text here end there end here");
618 label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
619 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
620 Vector3 textNaturalSize = label3.GetNaturalSize();
621 int lineSpacing = 20;
622 label3.SetProperty(TextLabel::Property::LINE_SPACING, lineSpacing);
623 Vector3 expectedNaturalSizeWithLineSpacing(textNaturalSize);
624 expectedNaturalSizeWithLineSpacing.height += lineSpacing;
625 DALI_TEST_EQUALS(expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION);
627 // Check the line spacing property
628 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::LINE_SPACING), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
629 label.SetProperty(TextLabel::Property::LINE_SPACING, 10.f);
630 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::LINE_SPACING), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
632 // Check the strikethrough property
633 strikethroughMapSet.Clear();
634 strikethroughMapSet.Insert("enable", true);
635 strikethroughMapSet.Insert("color", Color::RED);
636 strikethroughMapSet.Insert("height", 2.0f);
638 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
640 application.SendNotification();
641 application.Render();
643 strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
644 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
645 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
647 // Check the transparent strikethrough property for coverage.
648 strikethroughMapSet.Clear();
649 strikethroughMapSet.Insert("enable", true);
650 strikethroughMapSet.Insert("color", Color::TRANSPARENT);
651 strikethroughMapSet.Insert("height", 2.0f);
653 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
655 application.SendNotification();
656 application.Render();
658 strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
659 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
660 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
662 strikethroughMapSet.Clear();
663 strikethroughMapSet.Insert(Toolkit::DevelText::Strikethrough::Property::ENABLE, true);
664 strikethroughMapSet.Insert(Toolkit::DevelText::Strikethrough::Property::COLOR, Color::RED);
665 strikethroughMapSet.Insert(Toolkit::DevelText::Strikethrough::Property::HEIGHT, 2.0f);
667 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
669 application.SendNotification();
670 application.Render();
672 strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
673 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
674 std::vector<std::string> strikethroughIndicesConversionTable = {"enable", "color", "height"};
675 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet, strikethroughIndicesConversionTable), true, TEST_LOCATION);
677 strikethroughMapSet.Clear();
679 Property::Map strikethroughDisabledMapGet;
680 strikethroughDisabledMapGet.Insert("enable", false);
681 strikethroughDisabledMapGet.Insert("color", Color::RED);
682 strikethroughDisabledMapGet.Insert("height", 2.0f);
684 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
686 application.SendNotification();
687 application.Render();
689 strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
690 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughDisabledMapGet.Count(), TEST_LOCATION);
691 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughDisabledMapGet), true, TEST_LOCATION);
693 // Check the underline property
694 underlineMapSet.Clear();
695 underlineMapSet.Insert("enable", true);
696 underlineMapSet.Insert("color", Color::RED);
697 underlineMapSet.Insert("height", 1);
698 underlineMapSet.Insert("type", Text::Underline::SOLID);
699 underlineMapSet.Insert("dashWidth", 2);
700 underlineMapSet.Insert("dashGap", 1);
702 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
704 application.SendNotification();
705 application.Render();
707 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
708 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
709 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
711 underlineMapSet.Clear();
712 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::ENABLE, true);
713 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN);
714 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::HEIGHT, 2);
715 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::TYPE, Text::Underline::DASHED);
716 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_WIDTH, 2);
717 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_GAP, 1);
719 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
721 application.SendNotification();
722 application.Render();
724 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
725 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
726 std::vector<std::string> underlineIndicesConversionTable = {"enable", "color", "height", "type", "dashWidth", "dashGap"};
727 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet, underlineIndicesConversionTable), true, TEST_LOCATION);
729 underlineMapSet.Clear();
731 Property::Map underlineDisabledMapGet;
732 underlineDisabledMapGet.Insert("enable", false);
733 underlineDisabledMapGet.Insert("color", Color::GREEN);
734 underlineDisabledMapGet.Insert("height", 2);
735 underlineDisabledMapGet.Insert("type", Text::Underline::SOLID);
736 underlineDisabledMapGet.Insert("dashWidth", 2);
737 underlineDisabledMapGet.Insert("dashGap", 1);
739 label.SetProperty(TextLabel::Property::UNDERLINE, underlineDisabledMapGet);
741 application.SendNotification();
742 application.Render();
744 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
745 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION);
746 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineDisabledMapGet), true, TEST_LOCATION);
748 // Check the dashed underline property
749 underlineMapSet.Clear();
750 underlineMapSet.Insert("enable", true);
751 underlineMapSet.Insert("color", Color::RED);
752 underlineMapSet.Insert("height", 1);
753 underlineMapSet.Insert("type", Text::Underline::DASHED);
754 underlineMapSet.Insert("dashWidth", 2);
755 underlineMapSet.Insert("dashGap", 1);
757 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
759 application.SendNotification();
760 application.Render();
762 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
763 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
764 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
766 underlineMapSet.Clear();
767 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::ENABLE, true);
768 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN);
769 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::HEIGHT, 2);
770 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::TYPE, Text::Underline::DASHED);
771 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_WIDTH, 2);
772 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_GAP, 1);
774 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
776 application.SendNotification();
777 application.Render();
779 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
780 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
781 underlineIndicesConversionTable = {"enable", "color", "height", "type", "dashWidth", "dashGap"};
782 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet, underlineIndicesConversionTable), true, TEST_LOCATION);
784 underlineMapSet.Clear();
786 underlineDisabledMapGet.Clear();
787 underlineDisabledMapGet.Insert("enable", false);
788 underlineDisabledMapGet.Insert("color", Color::GREEN);
789 underlineDisabledMapGet.Insert("height", 2);
790 underlineDisabledMapGet.Insert("type", Text::Underline::DASHED);
791 underlineDisabledMapGet.Insert("dashWidth", 2);
792 underlineDisabledMapGet.Insert("dashGap", 1);
794 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
796 application.SendNotification();
797 application.Render();
799 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
800 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION);
801 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineDisabledMapGet), true, TEST_LOCATION);
803 // Check the double underline property
804 underlineMapSet.Clear();
805 underlineMapSet.Insert("enable", true);
806 underlineMapSet.Insert("color", Color::RED);
807 underlineMapSet.Insert("height", 1);
808 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
809 underlineMapSet.Insert("dashWidth", 2);
810 underlineMapSet.Insert("dashGap", 1);
812 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
814 application.SendNotification();
815 application.Render();
817 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
818 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
819 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
821 // Check the transparent double underline property for coverage.
822 underlineMapSet.Clear();
823 underlineMapSet.Insert("enable", true);
824 underlineMapSet.Insert("color", Color::TRANSPARENT);
825 underlineMapSet.Insert("height", 1);
826 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
827 underlineMapSet.Insert("dashWidth", 2);
828 underlineMapSet.Insert("dashGap", 1);
830 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
832 application.SendNotification();
833 application.Render();
835 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
836 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
837 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
839 underlineMapSet.Clear();
840 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::ENABLE, true);
841 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN);
842 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::HEIGHT, 2);
843 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::TYPE, Text::Underline::DOUBLE);
844 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_WIDTH, 2);
845 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_GAP, 1);
847 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
849 application.SendNotification();
850 application.Render();
852 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
853 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
854 underlineIndicesConversionTable = {"enable", "color", "height", "type", "dashWidth", "dashGap"};
855 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet, underlineIndicesConversionTable), true, TEST_LOCATION);
857 underlineMapSet.Clear();
859 underlineDisabledMapGet.Clear();
860 underlineDisabledMapGet.Insert("enable", false);
861 underlineDisabledMapGet.Insert("color", Color::GREEN);
862 underlineDisabledMapGet.Insert("height", 2);
863 underlineDisabledMapGet.Insert("type", Text::Underline::DOUBLE);
864 underlineDisabledMapGet.Insert("dashWidth", 2);
865 underlineDisabledMapGet.Insert("dashGap", 1);
867 label.SetProperty(TextLabel::Property::UNDERLINE, underlineDisabledMapGet);
869 application.SendNotification();
870 application.Render();
872 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
873 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION);
874 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineDisabledMapGet), true, TEST_LOCATION);
876 // Check the shadow property
878 Property::Map shadowMapSet;
879 Property::Map shadowMapGet;
881 shadowMapSet.Insert("color", Color::GREEN);
882 shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
883 shadowMapSet.Insert("blurRadius", 5.0f);
885 label.SetProperty(TextLabel::Property::SHADOW, shadowMapSet);
887 shadowMapGet = label.GetProperty<Property::Map>(TextLabel::Property::SHADOW);
888 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
889 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
891 shadowMapSet.Clear();
893 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE);
894 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0");
895 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f);
897 label.SetProperty(TextLabel::Property::SHADOW, shadowMapSet);
899 // Replace the offset (string) by a vector2
900 shadowMapSet.Clear();
901 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE);
902 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::OFFSET, Vector2(3.0, 3.0));
903 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f);
905 shadowMapGet = label.GetProperty<Property::Map>(TextLabel::Property::SHADOW);
906 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
907 std::vector<std::string> shadowIndicesConversionTable = {"color", "offset", "blurRadius"};
908 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet, shadowIndicesConversionTable), true, TEST_LOCATION);
910 shadowMapSet.Clear();
911 Property::Map shadowDisabledMapGet;
912 shadowDisabledMapGet.Insert("color", Color::BLUE);
913 shadowDisabledMapGet.Insert("offset", Vector2(0.0f, 0.0f));
914 shadowDisabledMapGet.Insert("blurRadius", 3.0f);
916 label.SetProperty(TextLabel::Property::SHADOW, shadowMapSet);
918 shadowMapGet = label.GetProperty<Property::Map>(TextLabel::Property::SHADOW);
919 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION);
920 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowDisabledMapGet), true, TEST_LOCATION);
922 // Check the emboss property
923 label.SetProperty(TextLabel::Property::EMBOSS, "Emboss properties");
924 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
926 // Check the outline property
928 // Test string type first
929 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
930 label.SetProperty(TextLabel::Property::OUTLINE, "Outline properties");
931 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
933 // Then test the property map type
934 Property::Map outlineMapSet;
935 Property::Map outlineMapGet;
937 outlineMapSet["color"] = Color::RED;
938 outlineMapSet["width"] = 2.0f;
939 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
941 outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
942 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
943 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
945 outlineMapSet.Clear();
946 outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
947 outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
948 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
950 outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
951 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
952 std::vector<std::string> outlineIndicesConversionTable = {"color", "width"};
953 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet, outlineIndicesConversionTable), true, TEST_LOCATION);
955 // Check the background property
956 Property::Map backgroundMapSet;
957 Property::Map backgroundMapGet;
959 backgroundMapSet["enable"] = true;
960 backgroundMapSet["color"] = Color::RED;
961 label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
963 backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
964 DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
965 DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet), true, TEST_LOCATION);
967 // Check the transparent background property for coverage
968 backgroundMapSet.Clear();
969 backgroundMapSet["enable"] = true;
970 backgroundMapSet["color"] = Color::TRANSPARENT;
971 label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
973 application.SendNotification();
974 application.Render();
976 backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
977 DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
978 DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet), true, TEST_LOCATION);
980 backgroundMapSet.Clear();
981 backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
982 backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
983 label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
985 backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
986 DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
987 std::vector<std::string> backgroundIndicesConversionTable = {"enable", "color"};
988 DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable), true, TEST_LOCATION);
990 // Check the pixel size of font
991 label.SetProperty(TextLabel::Property::PIXEL_SIZE, 20.f);
992 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
994 // Check the ellipsis property
995 DALI_TEST_CHECK(label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
996 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
997 DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
999 // Check the layout direction property
1000 label.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1001 DALI_TEST_EQUALS(label.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1003 // Check the line size property
1004 DALI_TEST_EQUALS(label.GetProperty<float>(DevelTextLabel::Property::MIN_LINE_SIZE), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1005 label.SetProperty(DevelTextLabel::Property::MIN_LINE_SIZE, 50.f);
1006 DALI_TEST_EQUALS(label.GetProperty<float>(DevelTextLabel::Property::MIN_LINE_SIZE), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1008 application.SendNotification();
1009 application.Render();
1014 int UtcDaliToolkitTextlabelAtlasRenderP(void)
1016 ToolkitTestApplication application;
1017 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
1018 TextLabel label = TextLabel::New("Test Text");
1019 DALI_TEST_CHECK(label);
1021 // Avoid a crash when core load gl resources.
1022 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1024 application.GetScene().Add(label);
1026 // Turn on all the effects
1027 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1028 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1030 Property::Map underlineMap;
1031 underlineMap.Insert("enable", true);
1032 underlineMap.Insert("color", Color::RED);
1033 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMap);
1035 Property::Map shadowMap;
1036 shadowMap.Insert("color", Color::BLUE);
1037 shadowMap.Insert("offset", Vector2(1.0f, 1.0f));
1038 label.SetProperty(TextLabel::Property::SHADOW, shadowMap);
1040 Property::Map strikethroughMap;
1041 strikethroughMap.Insert("enable", true);
1042 strikethroughMap.Insert("color", Color::GREEN);
1043 strikethroughMap.Insert("height", 2.0f);
1044 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMap);
1048 // Render some text with the shared atlas backend
1049 label.SetProperty(DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1050 application.SendNotification();
1051 application.Render();
1055 tet_result(TET_FAIL);
1060 // Render some text with the shared atlas backend
1061 label.SetProperty(DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED);
1062 application.SendNotification();
1063 application.Render();
1067 tet_result(TET_FAIL);
1072 int UtcDaliToolkitTextLabelLanguagesP(void)
1074 ToolkitTestApplication application;
1075 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
1076 TextLabel label = TextLabel::New();
1077 DALI_TEST_CHECK(label);
1079 application.GetScene().Add(label);
1081 const std::string scripts(
1082 " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
1083 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
1084 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
1085 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
1086 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
1087 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84."); // these characters on the last line are emojis.
1089 label.SetProperty(TextLabel::Property::TEXT, scripts);
1090 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::TEXT), scripts, TEST_LOCATION);
1092 application.SendNotification();
1093 application.Render();
1098 int UtcDaliToolkitTextLabelEmojisP(void)
1100 ToolkitTestApplication application;
1101 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
1102 TextLabel label = TextLabel::New();
1103 DALI_TEST_CHECK(label);
1105 application.GetScene().Add(label);
1107 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1109 char* pathNamePtr = get_current_dir_name();
1110 const std::string pathName(pathNamePtr);
1113 TextAbstraction::FontDescription fontDescription;
1114 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
1115 fontDescription.family = "BreezeColorEmoji";
1116 fontDescription.width = TextAbstraction::FontWidth::NONE;
1117 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
1118 fontDescription.slant = TextAbstraction::FontSlant::NONE;
1120 fontClient.GetFontId(fontDescription, EMOJI_FONT_SIZE);
1122 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>";
1123 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1124 label.SetProperty(TextLabel::Property::TEXT, emojis);
1126 Property::Map shadowMap;
1127 shadowMap.Insert("color", "green");
1128 shadowMap.Insert("offset", "2 2");
1129 label.SetProperty(TextLabel::Property::SHADOW, shadowMap);
1131 application.SendNotification();
1132 application.Render();
1134 // EMOJI + ZWJ + EMOJI case for coverage.
1135 const std::string emojiWithZWJ = "👩‍🔬";
1136 label.SetProperty(TextLabel::Property::TEXT, emojiWithZWJ);
1138 application.SendNotification();
1139 application.Render();
1141 // EMOJI Sequences case for coverage.
1142 std::string emojiSequences =
1143 "Glyphs not included in the font \n" //case for coverage when glyph is not included in the font
1144 "Text VS15 ☪︎\n" //text presentation sequence and selector
1145 "Color VS16 ☪️\n" //emoji presentation sequence and selector
1146 "Default ☪ \n" //default presentation
1147 "FamilyManWomanGirlBoy 👨‍👩‍👧‍👦\n" // emoji multi zwj sequence
1148 "WomanScientist 👩‍🔬\n" // emoji zwj sequence
1149 "WomanScientistLightSkinTone👩🏻‍🔬 \n" // emoji modifier sequence: skin tone & JWZ
1150 "LeftRightArrowText↔︎\n" // text presentation sequence and selector
1151 "LeftRightArrowEmoji↔️\n" // emoji presentation sequence and selector
1152 "SouthKoreaFlag🇰🇷\n" // emoji flag sequence
1153 "JordanFlag🇯🇴\n" // emoji flag sequence
1154 "EnglandFlag🏴󠁧󠁢󠁥󠁮󠁧󠁿\n" // emoji tag sequence like England flag
1155 "Runner 🏃‍➡️ \n"
1156 "VictoryHandMediumLightSkinTone:✌️🏼\n" // emoji modifier sequence: skin tone
1157 "RainbowFlag:🏳️‍🌈 \n" // emoji zwj sequence: Rainbow Flag
1158 "keycap# #️⃣ \n" // fully-qualified emoji keycap sequence
1159 "keycap#_text #⃣ \n" // unqualified emoji keycap sequence
1160 "keycap3 3️⃣ \n" // fully-qualified emoji keycap sequence
1161 "keycap3_text 3⃣ \n" // unqualified emoji keycap sequence
1162 "two adjacent glyphs ☪️️️☪️\n" // This line should be rendered as two adjacent glyphs
1163 "Digit 8️ 8︎ 8\n" // should be rendered according to selector
1164 "Surfing Medium Skin Female: 🏄🏼‍♀️\n" // Person Surfing + Medium Skin Tone +? Zero Width Joiner + Female Sign
1165 "SYMBOLS_NSLCL variation selector: 🅰️🅱️🅲︎🅳︎🅴︎\n" // 1F170 ~ 1F174 with variation selector, text vs emoji
1166 "SYMBOLS_NSLCL with VS15: 🅰︎🅱︎🅲︎🅳︎🅴︎\n" // 1F170 ~ 1F174 with VS15
1167 "SYMBOLS_NSLCL with VS16: 🅰️🅱️🅲️🅳️🅴️\n" // 1F170 ~ 1F174 with VS16
1171 label.SetProperty(TextLabel::Property::TEXT, emojiSequences);
1172 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1173 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1174 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
1176 application.SendNotification();
1177 application.Render();
1181 int UtcDaliToolkitTextlabelScrollingP(void)
1183 ToolkitTestApplication application;
1184 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
1185 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
1186 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
1188 DALI_TEST_CHECK(labelImmediate);
1189 DALI_TEST_CHECK(labelFinished);
1190 // Avoid a crash when core load gl resources.
1191 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1192 application.GetScene().Add(labelImmediate);
1193 // Turn on all the effects
1194 labelImmediate.SetProperty(TextLabel::Property::MULTI_LINE, false);
1195 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1196 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1197 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1198 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1200 application.GetScene().Add(labelFinished);
1201 // Turn on all the effects
1202 labelFinished.SetProperty(TextLabel::Property::MULTI_LINE, false);
1203 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1204 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1205 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1206 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1210 // Render some text with the shared atlas backend
1211 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1212 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1214 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1215 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1217 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1218 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1219 application.SendNotification();
1220 application.Render();
1222 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1223 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1224 application.SendNotification();
1225 application.Render();
1229 tet_result(TET_FAIL);
1235 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
1237 ToolkitTestApplication application;
1238 TextLabel labelShort = TextLabel::New("Some text to scroll");
1239 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!");
1241 DALI_TEST_CHECK(labelShort);
1242 DALI_TEST_CHECK(labelLong);
1243 // Avoid a crash when core load gl resources.
1244 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1245 application.GetScene().Add(labelShort);
1246 // Turn on all the effects
1247 labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1248 labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1249 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1250 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1251 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1252 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1254 application.GetScene().Add(labelLong);
1255 // Turn on all the effects
1256 labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1257 labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1258 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1259 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1260 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1261 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1265 // Render some text with the shared atlas backend
1266 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1267 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1268 application.SendNotification();
1269 application.Render();
1271 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1272 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1273 application.SendNotification();
1274 application.Render();
1278 tet_result(TET_FAIL);
1284 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
1286 ToolkitTestApplication application;
1287 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1288 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1290 DALI_TEST_CHECK(labelShort);
1291 DALI_TEST_CHECK(labelLong);
1292 // Avoid a crash when core load gl resources.
1293 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1294 application.GetScene().Add(labelShort);
1295 // Turn on all the effects
1296 labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1297 labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1298 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1299 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1300 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1301 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1303 application.GetScene().Add(labelLong);
1304 // Turn on all the effects
1305 labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1306 labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1307 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1308 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1309 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1310 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1314 // Render some text with the shared atlas backend
1315 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1316 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1317 application.SendNotification();
1318 application.Render();
1320 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1321 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1322 application.SendNotification();
1323 application.Render();
1327 tet_result(TET_FAIL);
1333 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
1335 ToolkitTestApplication application;
1336 TextLabel labelShort = TextLabel::New("Some text to scroll");
1337 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!");
1339 DALI_TEST_CHECK(labelShort);
1340 DALI_TEST_CHECK(labelLong);
1341 // Avoid a crash when core load gl resources.
1342 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1343 application.GetScene().Add(labelShort);
1344 // Turn on all the effects
1345 labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1346 labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1347 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1348 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1349 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1350 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1352 application.GetScene().Add(labelLong);
1353 // Turn on all the effects
1354 labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1355 labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1356 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1357 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1358 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1359 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1363 // Render some text with the shared atlas backend
1364 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1365 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1366 application.SendNotification();
1367 application.Render();
1369 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1370 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1371 application.SendNotification();
1372 application.Render();
1376 tet_result(TET_FAIL);
1382 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
1384 ToolkitTestApplication application;
1385 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1386 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1388 DALI_TEST_CHECK(labelShort);
1389 DALI_TEST_CHECK(labelLong);
1390 // Avoid a crash when core load gl resources.
1391 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1392 application.GetScene().Add(labelShort);
1393 // Turn on all the effects
1394 labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1395 labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1396 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1397 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1398 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1399 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1401 application.GetScene().Add(labelLong);
1402 // Turn on all the effects
1403 labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1404 labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1405 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1406 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1407 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1408 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1412 // Render some text with the shared atlas backend
1413 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1414 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1415 application.SendNotification();
1416 application.Render();
1418 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1419 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1420 application.SendNotification();
1421 application.Render();
1425 tet_result(TET_FAIL);
1431 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1433 ToolkitTestApplication application;
1434 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1435 TextLabel label = TextLabel::New("Some text to scroll");
1436 DALI_TEST_CHECK(label);
1437 // Avoid a crash when core load gl resources.
1438 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1439 application.GetScene().Add(label);
1440 label.SetProperty(Actor::Property::SIZE, Vector2(360.0f, 20.f));
1441 // Turn on all the effects
1442 label.SetProperty(TextLabel::Property::MULTI_LINE, false);
1443 label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1444 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1445 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1448 application.SendNotification();
1449 application.Render();
1451 unsigned int actorCount1 = label.GetChildCount();
1452 tet_printf("Initial actor count is(%d)\n", actorCount1);
1456 // Render some text with the shared atlas backend
1457 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1458 application.SendNotification();
1459 application.Render(2000);
1461 unsigned int actorCount1 = label.GetChildCount();
1462 tet_printf("Actor count after scrolling is(%d)\n", actorCount1);
1464 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1467 application.SendNotification();
1468 application.Render();
1470 unsigned int actorCount2 = label.GetChildCount();
1471 tet_printf("After changing color the actor count is(%d)\n", actorCount2);
1473 DALI_TEST_EQUALS(actorCount1, actorCount2, TEST_LOCATION);
1477 tet_result(TET_FAIL);
1483 int UtcDaliToolkitTextlabelScrollingN(void)
1485 ToolkitTestApplication application;
1486 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1488 TextLabel label = TextLabel::New("Some text to scroll");
1489 DALI_TEST_CHECK(label);
1491 application.GetScene().Add(label);
1493 // Avoid a crash when core load gl resources.
1494 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1496 // The text scrolling works only on single line text.
1497 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1499 // Turn on all the effects.
1500 label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1501 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1502 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1504 // Enable the auto scrolling effect.
1505 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1507 // The auto scrolling shouldn't be enabled.
1508 const bool enabled = label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>();
1509 DALI_TEST_CHECK(!enabled);
1514 int UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
1516 ToolkitTestApplication application;
1517 tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
1519 TextLabel label = TextLabel::New("Some text to scroll");
1520 DALI_TEST_CHECK(label);
1522 application.GetScene().Add(label);
1524 // Avoid a crash when core load gl resources.
1525 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1527 // 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);
1534 // Enable the auto scrolling effect.
1535 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1536 label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1538 // Disable the ellipsis
1539 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
1542 application.SendNotification();
1543 application.Render();
1545 // Stop auto scrolling
1546 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1548 // Check the ellipsis property
1549 DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
1553 tet_result(TET_FAIL);
1559 int UtcDaliToolkitTextlabelEllipsis(void)
1561 ToolkitTestApplication application;
1562 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1564 TextLabel label = TextLabel::New("Hello world");
1565 DALI_TEST_CHECK(label);
1567 // Avoid a crash when core load gl resources.
1568 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1570 application.GetScene().Add(label);
1572 // Turn on all the effects
1573 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1574 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1575 label.SetProperty(Actor::Property::SIZE, Vector2(360.0f, 10.f));
1580 application.SendNotification();
1581 application.Render();
1585 tet_result(TET_FAIL);
1588 label.SetProperty(TextLabel::Property::TEXT, "Hello world ");
1589 label.SetProperty(DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false);
1590 label.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 10.f));
1595 application.SendNotification();
1596 application.Render();
1600 tet_result(TET_FAIL);
1603 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1604 label.SetProperty(DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
1605 label.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 10.f));
1610 application.SendNotification();
1611 application.Render();
1615 tet_result(TET_FAIL);
1621 int UtcDaliToolkitTextlabelTextWrapMode(void)
1623 ToolkitTestApplication application;
1624 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1628 TextLabel label = TextLabel::New();
1629 label.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.f));
1630 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1631 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1633 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1634 application.GetScene().Add(label);
1636 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "WORD");
1637 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
1639 application.SendNotification();
1640 application.Render();
1642 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1643 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1645 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
1646 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1648 application.SendNotification();
1649 application.Render();
1651 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD);
1652 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
1654 application.SendNotification();
1655 application.Render();
1657 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1658 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1660 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER);
1661 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1663 application.SendNotification();
1664 application.Render();
1666 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1667 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1669 tet_infoline("Ensure invalid string does not change wrapping mode");
1670 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode");
1671 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1676 int UtcDaliToolkitTextLabelColorComponents(void)
1678 ToolkitTestApplication application;
1680 TextLabel label = TextLabel::New();
1681 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1682 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 1.0f, TEST_LOCATION);
1683 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 0.0f, TEST_LOCATION);
1684 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 0.0f, TEST_LOCATION);
1685 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1687 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::GREEN);
1688 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 0.0f, TEST_LOCATION);
1689 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 1.0f, TEST_LOCATION);
1690 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 0.0f, TEST_LOCATION);
1691 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1693 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLUE);
1694 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 0.0f, TEST_LOCATION);
1695 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 0.0f, TEST_LOCATION);
1696 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 1.0f, TEST_LOCATION);
1697 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1699 label.SetProperty(TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f);
1700 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 0.6f, TEST_LOCATION);
1701 DALI_TEST_EQUALS(label.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR), Vector4(0.0f, 0.0f, 1.0f, 0.6f), TEST_LOCATION);
1703 // Test a transparent text - Rendering should be skipped.
1704 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1705 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLUE);
1707 application.GetScene().Add(label);
1709 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1710 drawTrace.Enable(true);
1712 application.SendNotification();
1713 application.Render();
1715 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION); // Should be rendered
1717 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT);
1721 application.SendNotification();
1722 application.Render();
1724 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), false, TEST_LOCATION); // Rendering should be skipped
1726 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1730 application.SendNotification();
1731 application.Render();
1733 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION); // Should be rendered again
1738 int UtcDaliToolkitTextlabelTextStyle01(void)
1740 ToolkitTestApplication application;
1741 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1743 TextLabel label = TextLabel::New();
1744 label.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.f));
1745 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1746 label.SetProperty(TextLabel::Property::POINT_SIZE, 12);
1747 application.GetScene().Add(label);
1749 Property::Map outlineMapSet;
1750 Property::Map outlineMapGet;
1752 outlineMapSet["color"] = Color::BLUE;
1753 outlineMapSet["width"] = 2.0f;
1754 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
1756 application.SendNotification();
1757 application.Render();
1759 Property::Map shadowMapSet;
1760 shadowMapSet.Insert("color", "green");
1761 shadowMapSet.Insert("offset", "2 2");
1762 shadowMapSet.Insert("blurRadius", "3");
1763 label.SetProperty(TextLabel::Property::SHADOW, shadowMapSet);
1765 outlineMapSet["color"] = Color::RED;
1766 outlineMapSet["width"] = 0.0f;
1767 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
1769 application.SendNotification();
1770 application.Render();
1772 outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
1774 Property::Value* colorValue = outlineMapGet.Find("color");
1776 bool colorMatched(false);
1780 Property::Type valueType = colorValue->GetType();
1782 if(Property::STRING == valueType)
1784 std::string stringValue;
1785 colorValue->Get(stringValue);
1786 if(stringValue == "red")
1788 colorMatched = true;
1791 else if(Property::VECTOR4 == valueType)
1793 Vector4 colorVector4;
1794 colorValue->Get(colorVector4);
1795 if(colorVector4 == Color::RED)
1797 colorMatched = true;
1802 DALI_TEST_EQUALS(colorMatched, true, TEST_LOCATION);
1807 int UtcDaliToolkitTextlabelMultiline(void)
1809 ToolkitTestApplication application;
1810 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1812 TextLabel label = TextLabel::New();
1813 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world");
1814 label.SetProperty(TextLabel::Property::POINT_SIZE, 20);
1815 label.SetProperty(TextLabel::Property::MULTI_LINE, false);
1816 application.GetScene().Add(label);
1818 application.SendNotification();
1819 application.Render();
1821 int lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1822 DALI_TEST_EQUALS(lineCount, 1, TEST_LOCATION);
1824 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1826 application.SendNotification();
1827 application.Render();
1829 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1830 DALI_TEST_EQUALS(true, (lineCount > 1), TEST_LOCATION);
1835 int UtcDaliToolkitTextlabelTextDirection(void)
1837 ToolkitTestApplication application;
1838 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1840 TextLabel label = TextLabel::New();
1841 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT), TEST_LOCATION);
1843 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1844 label.SetProperty(TextLabel::Property::POINT_SIZE, 20);
1845 label.SetProperty(DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
1846 application.GetScene().Add(label);
1849 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT), TEST_LOCATION);
1852 label.SetProperty(TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ");
1853 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1855 // Test RTL text starting with weak character
1856 label.SetProperty(TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ");
1857 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1859 // Test RTL text string with emoji and weak character
1860 label.SetProperty(TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ");
1861 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1866 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1868 ToolkitTestApplication application;
1869 tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1871 TextLabel label = TextLabel::New();
1873 label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP);
1874 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1875 label.SetProperty(TextLabel::Property::POINT_SIZE, 15);
1876 label.SetProperty(TextLabel::Property::LINE_SPACING, 12);
1877 application.GetScene().Add(label);
1878 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::TOP), TEST_LOCATION);
1880 label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE);
1881 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::MIDDLE), TEST_LOCATION);
1883 label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM);
1884 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::BOTTOM), TEST_LOCATION);
1889 int UtcDaliToolkitTextLabelBitmapFont(void)
1891 ToolkitTestApplication application;
1892 tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1894 DevelText::BitmapFontDescription fontDescription;
1895 fontDescription.name = "Digits";
1896 fontDescription.underlinePosition = 0.f;
1897 fontDescription.underlineThickness = 0.f;
1899 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f});
1900 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f});
1901 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f});
1902 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f});
1903 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f});
1904 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f});
1905 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f});
1906 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f});
1907 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f});
1908 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f});
1909 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f});
1911 TextAbstraction::BitmapFont bitmapFont;
1912 DevelText::CreateBitmapFont(fontDescription, bitmapFont);
1914 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1915 fontClient.GetFontId(bitmapFont);
1917 TextLabel label = TextLabel::New();
1919 label.SetProperty(TextLabel::Property::TEXT, "0123456789:");
1920 label.SetProperty(TextLabel::Property::FONT_FAMILY, "Digits");
1922 // 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.
1923 DALI_TEST_EQUALS(label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1925 application.GetScene().Add(label);
1927 application.SendNotification();
1928 application.Render();
1930 // The text has been rendered if the height of the text-label is the height of the line.
1931 DALI_TEST_EQUALS(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1936 int ConvertPointToPixel(float point)
1938 unsigned int horizontalDpi = 0u;
1939 unsigned int verticalDpi = 0u;
1940 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1941 fontClient.GetDpi(horizontalDpi, verticalDpi);
1943 return (point * 72.f) / static_cast<float>(horizontalDpi);
1946 int UtcDaliToolkitTextlabelTextFit(void)
1948 ToolkitTestApplication application;
1949 tet_infoline(" UtcDaliToolkitTextlabelTextFit");
1950 TextLabel label = TextLabel::New();
1951 Vector2 size(460.0f, 100.0f);
1952 label.SetProperty(Actor::Property::SIZE, size);
1953 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1955 // connect to the text git changed signal.
1956 ConnectionTracker* testTracker = new ConnectionTracker();
1957 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
1958 bool textFitChangedSignal = false;
1959 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
1960 gTextFitChangedCallBackCalled = false;
1963 Property::Map textFitMapSet;
1964 textFitMapSet["enable"] = true;
1965 textFitMapSet["minSize"] = 10.f;
1966 textFitMapSet["maxSize"] = 100.f;
1967 textFitMapSet["stepSize"] = -1.f;
1968 textFitMapSet["fontSizeType"] = "pointSize";
1970 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
1971 label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
1973 application.GetScene().Add(label);
1975 application.SendNotification();
1976 application.Render();
1978 const Vector3 EXPECTED_NATURAL_SIZE(450.0f, 96.0f, 0.0f);
1979 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
1981 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
1982 DALI_TEST_CHECK(textFitChangedSignal);
1985 textFitMapSet.Clear();
1986 textFitMapSet["enable"] = true;
1987 textFitMapSet["minSize"] = ConvertPointToPixel(10.f);
1988 textFitMapSet["maxSize"] = ConvertPointToPixel(100.f);
1989 textFitMapSet["stepSize"] = ConvertPointToPixel(1.f);
1990 textFitMapSet["fontSizeType"] = "pixelSize";
1992 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
1994 application.SendNotification();
1995 application.Render();
1997 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2002 int UtcDaliToolkitTextlabelMaxTextureSet(void)
2004 ToolkitTestApplication application;
2005 tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
2007 DevelText::BitmapFontDescription fontDescription;
2008 fontDescription.name = "Digits";
2009 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f});
2011 TextAbstraction::BitmapFont bitmapFont;
2012 DevelText::CreateBitmapFont(fontDescription, bitmapFont);
2014 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2015 fontClient.GetFontId(bitmapFont);
2017 TextLabel label = TextLabel::New();
2018 label.SetProperty(TextLabel::Property::FONT_FAMILY, "Digits");
2019 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2020 label.SetProperty(TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded.");
2021 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2022 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2024 Property::Map underlineMapSet;
2025 underlineMapSet.Clear();
2026 underlineMapSet.Insert("enable", true);
2027 underlineMapSet.Insert("color", Color::RED);
2028 underlineMapSet.Insert("height", 1);
2029 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2030 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2032 Property::Map strikethroughMapSet;
2033 strikethroughMapSet.Clear();
2034 strikethroughMapSet.Insert("enable", true);
2035 strikethroughMapSet.Insert("color", Color::RED);
2036 strikethroughMapSet.Insert("height", 2.0f);
2037 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2038 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2040 application.GetScene().Add(label);
2042 application.SendNotification();
2043 application.Render();
2045 const int maxTextureSize = Dali::GetMaxTextureSize();
2046 // Whether the rendered text is greater than maxTextureSize
2047 DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2049 // Check if the number of renderers is greater than 1.
2050 DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2053 underlineMapSet.Clear();
2054 underlineMapSet.Insert("enable", false);
2055 underlineMapSet.Insert("color", Color::BLUE);
2056 underlineMapSet.Insert("height", 0);
2057 underlineMapSet.Insert("type", Text::Underline::DASHED);
2058 underlineMapSet.Insert("dashWidth", 2);
2059 underlineMapSet.Insert("dashGap", 1);
2060 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2061 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2063 application.GetScene().Add(label);
2065 application.SendNotification();
2066 application.Render();
2068 // Whether the rendered text is greater than maxTextureSize
2069 DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2071 // Check if the number of renderers is greater than 1.
2072 DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2075 underlineMapSet.Clear();
2076 underlineMapSet.Insert("enable", false);
2077 underlineMapSet.Insert("color", Color::BLUE);
2078 underlineMapSet.Insert("height", 0);
2079 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
2080 underlineMapSet.Insert("dashWidth", 2);
2081 underlineMapSet.Insert("dashGap", 1);
2082 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2083 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2085 application.GetScene().Add(label);
2087 application.SendNotification();
2088 application.Render();
2090 // Whether the rendered text is greater than maxTextureSize
2091 DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2093 // Check if the number of renderers is greater than 1.
2094 DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2096 // Coverage test for case of layoutSize is bigger than maxTextureSize
2097 float max_value = static_cast<float>(std::numeric_limits<uint16_t>::max());
2098 label.SetProperty(Actor::Property::SIZE, Vector2(max_value, 30.0f));
2099 application.SendNotification();
2100 application.Render();
2106 int UtcDaliToolkitTextlabelStrikethroughExceedsWidthAndHeight(void)
2108 ToolkitTestApplication application;
2109 tet_infoline(" UtcDaliToolkitTextlabelStrikethroughExceedsWidthAndHeight");
2111 TextLabel label = TextLabel::New();
2112 label.SetProperty(TextLabel::Property::TEXT, "Test");
2113 label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2114 //Exeeding BufferWidth
2115 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 400.0f));
2116 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2117 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2119 application.GetScene().Add(label);
2120 application.SendNotification();
2121 application.Render();
2123 Property::Map strikethroughMapSet;
2124 strikethroughMapSet.Clear();
2125 strikethroughMapSet.Insert("enable", true);
2126 strikethroughMapSet.Insert("color", Color::BLUE);
2127 strikethroughMapSet.Insert("height", 2.0f);
2128 label.SetProperty(TextLabel::Property::TEXT, "Test1");
2129 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2130 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2131 application.GetScene().Add(label);
2132 application.SendNotification();
2133 application.Render();
2134 // Check if the number of renderers is 1.
2135 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2137 label = TextLabel::New();
2138 label.SetProperty(TextLabel::Property::TEXT, "Test");
2139 label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2141 //Exeeding BufferHeight
2142 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.0f));
2143 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2144 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2146 application.GetScene().Add(label);
2147 application.SendNotification();
2148 application.Render();
2150 strikethroughMapSet.Clear();
2151 strikethroughMapSet.Insert("enable", true);
2152 strikethroughMapSet.Insert("color", Color::BLUE);
2153 strikethroughMapSet.Insert("height", 2.0f);
2154 label.SetProperty(TextLabel::Property::TEXT, "Test2");
2155 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2156 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2157 application.GetScene().Add(label);
2158 application.SendNotification();
2159 application.Render();
2160 // Check if the number of renderers is 1.
2161 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2166 int UtcDaliToolkitTextlabelUnderlineExceedsWidth(void)
2168 ToolkitTestApplication application;
2169 tet_infoline(" UtcDaliToolkitTextlabelUnderlineExceedsWidth");
2171 TextLabel label = TextLabel::New();
2172 label.SetProperty(TextLabel::Property::TEXT, "Test");
2173 label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2174 //Exeeding BufferWidth
2175 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 400.0f));
2176 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2177 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2179 application.GetScene().Add(label);
2180 application.SendNotification();
2181 application.Render();
2183 Property::Map underlineMapSet;
2186 underlineMapSet.Clear();
2187 underlineMapSet.Insert("enable", true);
2188 underlineMapSet.Insert("color", Color::BLUE);
2189 underlineMapSet.Insert("height", 1);
2190 underlineMapSet.Insert("type", Text::Underline::SOLID);
2191 underlineMapSet.Insert("dashWidth", 2);
2192 underlineMapSet.Insert("dashGap", 1);
2193 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2194 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2196 application.GetScene().Add(label);
2198 application.SendNotification();
2199 application.Render();
2201 // Check if the number of renderers is 1.
2202 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2205 underlineMapSet.Clear();
2206 underlineMapSet.Insert("enable", true);
2207 underlineMapSet.Insert("color", Color::BLUE);
2208 underlineMapSet.Insert("height", 1);
2209 underlineMapSet.Insert("type", Text::Underline::DASHED);
2210 underlineMapSet.Insert("dashWidth", 2);
2211 underlineMapSet.Insert("dashGap", 1);
2212 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2213 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2215 application.GetScene().Add(label);
2217 application.SendNotification();
2218 application.Render();
2220 // Check if the number of renderers is 1.
2221 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2224 underlineMapSet.Clear();
2225 underlineMapSet.Insert("enable", true);
2226 underlineMapSet.Insert("color", Color::BLUE);
2227 underlineMapSet.Insert("height", 1);
2228 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
2229 underlineMapSet.Insert("dashWidth", 2);
2230 underlineMapSet.Insert("dashGap", 1);
2231 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2232 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2234 application.GetScene().Add(label);
2236 application.SendNotification();
2237 application.Render();
2239 // Check if the number of renderers is 1.
2240 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2245 int UtcDaliToolkitTextlabelLastCharacterIndex(void)
2247 ToolkitTestApplication application;
2248 tet_infoline(" UtcDaliToolkitTextlabelLastCharacterIndex");
2250 Vector2 size(300.0f, 100.0f);
2252 Dali::Toolkit::DevelText::RendererParameters textParameters;
2253 textParameters.text = "This is a sample text to get the last index.";
2254 textParameters.layout = "multiLine";
2255 textParameters.fontSize = 20.f;
2256 textParameters.textWidth = 300u;
2257 textParameters.textHeight = 100u;
2258 textParameters.ellipsisEnabled = true;
2259 Dali::Property::Array indexArray = Dali::Toolkit::DevelText::GetLastCharacterIndex(textParameters);
2261 DALI_TEST_CHECK(!indexArray.Empty());
2262 DALI_TEST_EQUALS(indexArray.GetElementAt(0).Get<int>(), 10, TEST_LOCATION);
2267 int UtcDaliToolkitTextlabelFontSizeScale(void)
2269 ToolkitTestApplication application;
2270 tet_infoline(" UtcDaliToolkitTextlabelFontSizeScale");
2272 TextLabel label = TextLabel::New();
2273 label.SetProperty(TextLabel::Property::POINT_SIZE, 30.f);
2274 label.SetProperty(TextLabel::Property::TEXT, "Test");
2275 Vector3 nonScaledSize = label.GetNaturalSize();
2277 TextLabel labelScaled = TextLabel::New();
2278 labelScaled.SetProperty(TextLabel::Property::POINT_SIZE, 15.f);
2279 labelScaled.SetProperty(Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f);
2280 labelScaled.SetProperty(TextLabel::Property::TEXT, "Test");
2281 Vector3 scaledSize = labelScaled.GetNaturalSize();
2283 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
2285 label.SetProperty(TextLabel::Property::PIXEL_SIZE, 30.f);
2286 label.SetProperty(TextLabel::Property::TEXT, "Test");
2287 nonScaledSize = label.GetNaturalSize();
2289 labelScaled.SetProperty(TextLabel::Property::PIXEL_SIZE, 15.f);
2290 labelScaled.SetProperty(Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f);
2291 labelScaled.SetProperty(TextLabel::Property::TEXT, "Test");
2292 scaledSize = labelScaled.GetNaturalSize();
2294 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
2299 // Positive test for the anchorClicked signal.
2300 int UtcDaliToolkitTextlabelAnchorClicked(void)
2302 ToolkitTestApplication application;
2303 tet_infoline(" UtcDaliToolkitTextlabelAnchorClicked");
2304 TextLabel label = TextLabel::New();
2305 DALI_TEST_CHECK(label);
2307 application.GetScene().Add(label);
2309 // connect to the anchor clicked signal.
2310 ConnectionTracker* testTracker = new ConnectionTracker();
2311 DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
2312 bool anchorClickedSignal = false;
2313 label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
2315 gAnchorClickedCallBackCalled = false;
2316 label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
2317 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2318 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2319 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2320 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2322 application.SendNotification();
2323 application.Render();
2325 // Create a tap event to touch the text label.
2326 TestGenerateTap(application, 5.0f, 25.0f, 100);
2327 application.SendNotification();
2328 application.Render();
2330 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2331 DALI_TEST_CHECK(anchorClickedSignal);
2334 gAnchorClickedCallBackCalled = false;
2335 anchorClickedSignal = false;
2336 label.SetProperty(TextLabel::Property::TEXT, "");
2337 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, false);
2339 application.SendNotification();
2340 application.Render();
2343 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2344 label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
2345 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2346 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2347 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2349 application.SendNotification();
2350 application.Render();
2352 // Create a tap event to touch the text label.
2353 TestGenerateTap(application, 5.0f, 25.0f, 200);
2354 application.SendNotification();
2355 application.Render();
2357 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2358 DALI_TEST_CHECK(anchorClickedSignal);
2360 gAnchorClickedCallBackNotCalled = true;
2361 // Tap the outside of anchor, callback should not be called.
2362 TestGenerateTap(application, 150.f, 100.f, 300);
2363 application.SendNotification();
2364 application.Render();
2366 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
2371 int UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize(void)
2373 ToolkitTestApplication application;
2374 tet_infoline(" UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize ");
2376 //TextLabel is not using Atlas but this is to unify font-size on text-controllers
2378 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
2379 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
2380 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
2382 // Create a text editor
2383 TextLabel textLabel = TextLabel::New();
2384 //Set size to avoid automatic eliding
2385 textLabel.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
2386 //Set very large font-size using point-size
2387 textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 1000);
2388 //Specify font-family
2389 textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2390 //Set text to check if appear or not
2391 textLabel.SetProperty(TextLabel::Property::TEXT, "A");
2393 application.GetScene().Add(textLabel);
2395 application.SendNotification();
2396 application.Render();
2397 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
2398 Vector3 naturalSize = textLabel.GetNaturalSize();
2400 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
2401 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
2406 int UtcDaliTextLabelHyphenWrapMode(void)
2408 ToolkitTestApplication application;
2409 tet_infoline(" UtcDaliTextLabelHyphenWrapMode ");
2412 TextLabel label = TextLabel::New();
2413 label.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
2414 label.SetProperty(TextLabel::Property::POINT_SIZE, 12.f);
2415 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2416 application.GetScene().Add(label);
2417 application.SendNotification();
2418 application.Render();
2420 label.SetProperty(TextLabel::Property::TEXT, "Hi Experimen");
2421 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
2422 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::HYPHENATION), TEST_LOCATION);
2424 application.SendNotification();
2425 application.Render();
2427 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2433 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
2435 label.SetProperty(TextLabel::Property::TEXT, "Hi Experimen");
2436 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
2437 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::MIXED), TEST_LOCATION);
2439 application.SendNotification();
2440 application.Render();
2442 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2449 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
2454 int utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged(void)
2456 ToolkitTestApplication application;
2458 tet_infoline(" utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged ");
2460 int lineCountBefore = 0;
2461 int lineCountAfter = 0;
2463 // Create a text editor
2464 TextLabel textLabel = TextLabel::New();
2465 //Set very large font-size using point-size
2466 textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 10);
2467 //Specify font-family
2468 textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2470 textLabel.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.f));
2471 //Set text longer than width of textLabel
2472 textLabel.SetProperty(TextLabel::Property::TEXT, "Short text");
2473 //Set line wrap mode Character
2474 textLabel.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
2475 textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
2477 application.GetScene().Add(textLabel);
2479 application.SendNotification();
2480 application.Render();
2482 lineCountBefore = textLabel.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2484 textLabel.SetProperty(TextLabel::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
2485 lineCountAfter = textLabel.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2487 // When the text changed, the Line-count should be updated according to new text.
2488 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
2489 DALI_TEST_EQUALS(lineCountBefore, 1, TEST_LOCATION);
2490 DALI_TEST_GREATER(lineCountAfter, 1, TEST_LOCATION);
2495 int utcDaliTextLabelGeometryRTL(void)
2497 ToolkitTestApplication application;
2498 tet_infoline(" utcDaliTextLabelGeometryRTL");
2500 TextLabel label = TextLabel::New();
2501 DALI_TEST_CHECK(label);
2503 application.GetScene().Add(label);
2505 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2506 label.SetProperty(Actor::Property::SIZE, Vector2(150.f, 100.f));
2507 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2508 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2509 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2510 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2511 label.SetProperty(TextLabel::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر");
2513 // Avoid a crash when core load gl resources.
2514 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2516 // Render and notify
2517 application.SendNotification();
2518 application.Render();
2520 unsigned int expectedCount = 4;
2521 unsigned int startIndex = 3;
2522 unsigned int endIndex = 24;
2524 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2525 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2527 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2528 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2530 Vector<Vector2> expectedSizes;
2531 Vector<Vector2> expectedPositions;
2533 expectedPositions.PushBack(Vector2(24, 0));
2534 expectedSizes.PushBack(Vector2(33, 25));
2536 expectedPositions.PushBack(Vector2(-1, 25));
2537 expectedSizes.PushBack(Vector2(52, 25));
2539 expectedPositions.PushBack(Vector2(-1, 50));
2540 expectedSizes.PushBack(Vector2(59, 25));
2542 expectedPositions.PushBack(Vector2(73, 75));
2543 expectedSizes.PushBack(Vector2(37, 25));
2545 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2550 int utcDaliTextLabelGeometryGlyphMiddle(void)
2552 ToolkitTestApplication application;
2553 tet_infoline(" utcDaliTextLabelGeometryGlyphMiddle");
2555 TextLabel label = TextLabel::New();
2556 DALI_TEST_CHECK(label);
2558 application.GetScene().Add(label);
2560 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2561 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2562 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2563 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2564 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2565 label.SetProperty(TextLabel::Property::TEXT, "لا تحتوي على لا");
2567 // Avoid a crash when core load gl resources.
2568 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2570 // Render and notify
2571 application.SendNotification();
2572 application.Render();
2574 unsigned int expectedCount = 1;
2575 unsigned int startIndex = 1;
2576 unsigned int endIndex = 13;
2578 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2579 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2581 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2582 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2584 Vector<Vector2> expectedSizes;
2585 Vector<Vector2> expectedPositions;
2587 expectedPositions.PushBack(Vector2(6, 0));
2588 expectedSizes.PushBack(Vector2(124, 25));
2590 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2595 int utcDaliTextLabelGeometryOneGlyph(void)
2597 ToolkitTestApplication application;
2598 tet_infoline(" utcDaliTextLabelGeometryOneGlyph ");
2600 TextLabel label = TextLabel::New();
2601 DALI_TEST_CHECK(label);
2603 application.GetScene().Add(label);
2605 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2606 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2607 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2608 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2609 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2610 label.SetProperty(TextLabel::Property::TEXT, "H");
2612 // Avoid a crash when core load gl resources.
2613 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2615 // Render and notify
2616 application.SendNotification();
2617 application.Render();
2619 unsigned int expectedCount = 1;
2620 unsigned int startIndex = 0;
2621 unsigned int endIndex = 0;
2623 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2624 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2626 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2627 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2629 Vector<Vector2> expectedSizes;
2630 Vector<Vector2> expectedPositions;
2632 expectedPositions.PushBack(Vector2(-2, 0));
2633 expectedSizes.PushBack(Vector2(16, 25));
2635 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2641 int utcDaliTextLabelGeometryNullPtr(void)
2643 ToolkitTestApplication application;
2644 tet_infoline("utcDaliTextLabelGeometryNullPtr");
2646 TextLabel label = TextLabel::New();
2647 DALI_TEST_CHECK(label);
2649 application.GetScene().Add(label);
2651 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2652 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2653 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2654 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2655 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2656 label.SetProperty(TextLabel::Property::TEXT, "");
2658 // Avoid a crash when core load gl resources.
2659 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2661 unsigned int expectedCount = 0;
2662 unsigned int startIndex = 0;
2663 unsigned int endIndex = 0;
2665 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2666 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2668 // Render and notify
2669 application.SendNotification();
2670 application.Render();
2672 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2673 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2678 int UtcDaliToolkitTextlabelEllipsisPositionProperty(void)
2680 ToolkitTestApplication application;
2681 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty ");
2682 TextLabel textLabel = TextLabel::New();
2684 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Default is END");
2685 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
2687 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START");
2688 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
2689 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
2691 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE");
2692 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
2693 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
2695 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END");
2696 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
2697 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
2699 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using integer");
2700 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 1);
2701 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
2703 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using integer");
2704 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 2);
2705 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
2707 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using integer");
2708 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 0);
2709 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
2711 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
2712 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "START");
2713 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
2715 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
2716 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "MIDDLE");
2717 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
2719 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
2720 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "END");
2721 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
2723 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
2724 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "start");
2725 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
2727 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
2728 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "middle");
2729 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
2731 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
2732 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "end");
2733 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
2738 int UtcDaliToolkitTextLabelStrikethroughGeneration(void)
2740 ToolkitTestApplication application;
2741 tet_infoline(" UtcDaliToolkitTextLabelStrikethroughGeneration");
2743 TextLabel textLabel = TextLabel::New();
2744 textLabel.SetProperty(TextLabel::Property::TEXT, "Test");
2745 textLabel.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
2746 textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 10);
2747 textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2749 application.GetScene().Add(textLabel);
2750 application.SendNotification();
2751 application.Render();
2753 Property::Map strikethroughMapSet;
2754 Property::Map strikethroughMapGet;
2756 strikethroughMapSet.Insert("enable", true);
2757 strikethroughMapSet.Insert("color", Color::RED);
2758 strikethroughMapSet.Insert("height", 2.0f);
2760 // Check the strikethrough property
2761 textLabel.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2762 strikethroughMapGet = textLabel.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
2763 textLabel.SetProperty(TextLabel::Property::TEXT, "Test1");
2764 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
2765 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
2767 // Render and notify
2768 application.SendNotification();
2769 application.Render();
2771 strikethroughMapSet.Clear();
2772 strikethroughMapGet.Clear();
2777 int UtcDaliToolkitTextLabelMarkupRelativeLineHeight(void)
2779 ToolkitTestApplication application;
2780 tet_infoline(" UtcDaliToolkitTextLabelMarkupRelativeLineHeight");
2782 TextLabel label = TextLabel::New();
2783 label.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
2784 label.SetProperty(TextLabel::Property::POINT_SIZE, 10);
2785 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2786 label.SetProperty(TextLabel::Property::TEXT, "line 1\nline 2\nline 3\nline 4\nline 5");
2787 label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
2788 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
2789 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2791 TextLabel labelSingleLineParagraph = TextLabel::New();
2792 labelSingleLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
2793 labelSingleLineParagraph.SetProperty(TextLabel::Property::POINT_SIZE, 10);
2794 labelSingleLineParagraph.SetProperty(TextLabel::Property::MULTI_LINE, true);
2795 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");
2796 labelSingleLineParagraph.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
2797 labelSingleLineParagraph.SetProperty(TextLabel::Property::ELLIPSIS, false);
2798 labelSingleLineParagraph.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2800 TextLabel labelMultiLineParagraph = TextLabel::New();
2801 labelMultiLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
2802 labelMultiLineParagraph.SetProperty(TextLabel::Property::POINT_SIZE, 10);
2803 labelMultiLineParagraph.SetProperty(TextLabel::Property::MULTI_LINE, true);
2804 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");
2805 labelMultiLineParagraph.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
2806 labelMultiLineParagraph.SetProperty(TextLabel::Property::ELLIPSIS, false);
2807 labelMultiLineParagraph.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2809 application.GetScene().Add(label);
2810 application.GetScene().Add(labelSingleLineParagraph);
2811 application.GetScene().Add(labelMultiLineParagraph);
2812 application.SendNotification();
2813 application.Render();
2815 Vector3 naturalSize = label.GetNaturalSize();
2816 Vector3 relativeSingleNaturalSize = labelSingleLineParagraph.GetNaturalSize();
2817 Vector3 relativeMultiNaturalSize = labelMultiLineParagraph.GetNaturalSize();
2819 float lineSize = naturalSize.y / 5.0f; //total size/number of lines
2821 //no effect of relative line size for paragraph with single line
2822 DALI_TEST_EQUALS(naturalSize.y, relativeSingleNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2824 DALI_TEST_EQUALS(lineSize * 8.5f, relativeMultiNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2829 int UtcDaliToolkitTextLabelRelativeLineHeight(void)
2831 ToolkitTestApplication application;
2832 tet_infoline(" UtcDaliToolkitTextLabelRelativeLineHeight");
2834 TextLabel label = TextLabel::New();
2835 label.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
2836 label.SetProperty(TextLabel::Property::POINT_SIZE, 10);
2837 label.SetProperty(TextLabel::Property::TEXT, "Hello\nWorld");
2839 application.GetScene().Add(label);
2840 application.SendNotification();
2841 application.Render();
2843 Vector3 naturalSize = label.GetNaturalSize();
2845 label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 0.5f);
2847 application.SendNotification();
2848 application.Render();
2850 Vector3 relativeNaturalSize = label.GetNaturalSize();
2852 DALI_TEST_EQUALS(naturalSize.y, relativeNaturalSize.y, TEST_LOCATION);
2854 label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 2.0f);
2856 application.SendNotification();
2857 application.Render();
2859 relativeNaturalSize = label.GetNaturalSize();
2861 DALI_TEST_EQUALS(naturalSize.y * 2, relativeNaturalSize.y, TEST_LOCATION);
2865 int UtcDaliTextLabelCharacterSpacing(void)
2867 ToolkitTestApplication application;
2868 tet_infoline(" UtcDaliTextLabelCharacterSpacing ");
2870 TextLabel textLabel = TextLabel::New();
2872 textLabel.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
2874 application.GetScene().Add(textLabel);
2875 application.SendNotification();
2876 application.Render();
2878 textLabel.SetProperty(TextLabel::Property::TEXT, "Hi Experiment");
2879 textLabel.SetProperty(DevelTextLabel::Property::CHARACTER_SPACING, 10.f);
2880 DALI_TEST_EQUALS(textLabel.GetProperty<float>(DevelTextLabel::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2882 application.SendNotification();
2883 application.Render();
2888 int UtcDaliTextTextLabelSizeNegativeLineSpacing(void)
2890 ToolkitTestApplication application;
2891 tet_infoline("UtcDaliTextTextLabelSizeNegativeLineSpacing");
2893 TextLabel label = TextLabel::New();
2895 float lineSpacing = -20.f;
2897 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
2898 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
2899 label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
2900 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2901 label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
2903 application.GetScene().Add(label);
2904 application.SendNotification();
2905 application.Render();
2907 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, 0, 123);
2908 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, 0, 123);
2910 Vector2 lastLinePos = positionsList[positionsList.Size() - 1];
2911 Vector2 lastLineSize = sizeList[sizeList.Size() - 1];
2913 DALI_TEST_EQUALS(sizeList[0].y * (sizeList.Size() - 1), lastLinePos.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2914 DALI_TEST_EQUALS(sizeList[0].y - lineSpacing, lastLineSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2916 application.SendNotification();
2917 application.Render();
2922 int UtcDaliTextLabelNegativeLineSpacingWithEllipsis(void)
2924 ToolkitTestApplication application;
2925 tet_infoline("UtcDaliTextLabelNegativeLineSpacingWithEllipsis");
2927 TextLabel label = TextLabel::New();
2929 float lineSpacing = -20.f;
2931 label.SetProperty(Actor::Property::SIZE, Vector2(480.0f, 100.f));
2932 label.SetProperty(TextLabel::Property::POINT_SIZE, 11.0f);
2933 label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
2934 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2935 label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
2936 label.SetProperty(TextLabel::Property::ELLIPSIS, true);
2938 application.GetScene().Add(label);
2939 application.SendNotification();
2940 application.Render();
2942 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, 0, 123);
2944 int lineCount = sizeList.Size();
2945 DALI_TEST_EQUALS(4, lineCount, TEST_LOCATION);
2947 application.SendNotification();
2948 application.Render();
2953 int UtcDaliToolkitTextlabelParagraphTag(void)
2955 ToolkitTestApplication application;
2956 tet_infoline(" UtcDaliToolkitTextlabelParagraphTag");
2957 TextLabel labelNewlineSeparator = TextLabel::New();
2958 TextLabel labelParagraphTag = TextLabel::New();
2959 DALI_TEST_CHECK(labelNewlineSeparator);
2960 DALI_TEST_CHECK(labelParagraphTag);
2962 application.GetScene().Add(labelNewlineSeparator);
2963 application.GetScene().Add(labelParagraphTag);
2965 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
2966 labelNewlineSeparator.SetProperty(TextLabel::Property::MULTI_LINE, true);
2967 labelNewlineSeparator.SetProperty(TextLabel::Property::ELLIPSIS, false);
2968 labelNewlineSeparator.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2969 labelNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2970 labelNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2971 labelNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2972 labelNewlineSeparator.SetProperty(TextLabel::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
2974 labelParagraphTag.SetProperty(TextLabel::Property::MULTI_LINE, true);
2975 labelParagraphTag.SetProperty(TextLabel::Property::ELLIPSIS, false);
2976 labelParagraphTag.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2977 labelParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2978 labelParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2979 labelParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2980 labelParagraphTag.SetProperty(TextLabel::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
2982 application.SendNotification();
2983 application.Render();
2985 Vector3 textNaturalSizeNewlineSeparator = labelNewlineSeparator.GetNaturalSize();
2986 Vector3 textNaturalSizeParagraphTag = labelParagraphTag.GetNaturalSize();
2988 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
2990 application.SendNotification();
2991 application.Render();