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.
18 #include <bits/stdint-uintn.h>
22 #include <dali-toolkit-test-suite-utils.h>
23 #include <dali-toolkit/dali-toolkit.h>
25 #include <dali-toolkit/internal/controls/text-controls/text-label-impl.h>
26 #include <dali-toolkit/internal/text/rendering/text-typesetter.h>
27 #include <dali-toolkit/internal/text/rendering/view-model.h>
28 #include <dali-toolkit/internal/text/text-controller-impl.h>
29 #include <dali-toolkit/internal/text/text-controller.h>
32 using namespace Toolkit;
35 int UtcDaliTextLabelMarkupUnderline(void)
37 ToolkitTestApplication application;
38 tet_infoline(" UtcDaliTextLabelMarkupUnderline ");
40 TextLabel textLabel = TextLabel::New();
42 application.GetScene().Add(textLabel);
44 textLabel.SetProperty(TextLabel::Property::TEXT, "<u>ABC</u>EF<u>GH</u>");
45 textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
47 application.SendNotification();
50 uint32_t expectedNumberOfUnderlinedGlyphs = 5u;
52 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
53 const Text::Length numberOfUnderlineRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns();
55 DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlinedGlyphs, TEST_LOCATION);
57 Vector<UnderlinedGlyphRun> underlineRuns;
58 underlineRuns.Resize(numberOfUnderlineRuns);
59 textLabelImpl.GetTextController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns);
62 DALI_TEST_EQUALS(underlineRuns[0u].glyphRun.glyphIndex, 0u, TEST_LOCATION);
63 DALI_TEST_EQUALS(underlineRuns[1u].glyphRun.glyphIndex, 1u, TEST_LOCATION);
64 DALI_TEST_EQUALS(underlineRuns[2u].glyphRun.glyphIndex, 2u, TEST_LOCATION);
67 DALI_TEST_EQUALS(underlineRuns[3u].glyphRun.glyphIndex, 5u, TEST_LOCATION);
68 DALI_TEST_EQUALS(underlineRuns[4u].glyphRun.glyphIndex, 6u, TEST_LOCATION);
73 int UtcDaliTextLabelMarkupUnderlineAttributes(void)
75 ToolkitTestApplication application;
76 tet_infoline(" UtcDaliTextLabelMarkupUnderlineAttributes ");
78 TextLabel textLabel = TextLabel::New();
80 application.GetScene().Add(textLabel);
82 std::string testText =
83 "start<u>ABC1</u>then"
84 "<u type='solid'>ABC2</u>then"
85 "<u type='dashed'>ABC3</u>then"
86 "<u type='double'>ABC4</u>then"
87 "<u color='green'>ABC5</u>then"
88 "<u height='5.0f'>ABC6</u>then"
89 "<u type='dashed' dash-gap='3.0f'>ABC7</u>then"
90 "<u type='dashed' dash-width='4.0f'>ABC8</u>then"
91 "<u color='blue' type='dashed' height='4.0f' dash-gap='2.0f' dash-width='3.0f'>ABC9</u>end"
95 textLabel.SetProperty(TextLabel::Property::TEXT, testText);
96 textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
98 application.SendNotification();
101 const uint32_t NUMBER_OF_CASES = 9u;
102 uint32_t expectedNumberOfUnderlinedGlyphs = 36u;
104 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
105 const Text::Length numberOfUnderlineRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns();
107 DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlinedGlyphs, TEST_LOCATION);
109 Vector<UnderlinedGlyphRun> underlineRuns;
110 underlineRuns.Resize(numberOfUnderlineRuns);
111 textLabelImpl.GetTextController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns);
118 GlyphIndex startGlyphIndex;
119 GlyphIndex endGlyphIndex;
120 UnderlineStyleProperties properties;
131 Text::Underline::SOLID,
143 //<u type='solid'>ABC2</u>
144 {"<u type='solid'>ABC2</u>",
150 Text::Underline::SOLID,
162 //<u type='dashed'>ABC3</u>
163 {"<u type='dashed'>ABC3</u>",
169 Text::Underline::DASHED,
181 //<u type='double'>ABC4</u>
182 {"<u type='double'>ABC4</u>",
188 Text::Underline::DOUBLE,
200 //<u color='green'>ABC5</u>
201 {"<u color='green'>ABC5</u>",
207 Text::Underline::SOLID,
219 //<u height='5.0f'>ABC6</u>
220 {"<u height='5.0f'>ABC6</u>",
226 Text::Underline::SOLID,
238 //<u type='dashed' dash-gap='3.0f'>ABC7</u>
239 {"<u type='dashed' dash-gap='3.0f'>ABC7</u>",
245 Text::Underline::DASHED,
257 //<u type='dashed' dash-width='4.0f'>ABC8</u>
258 {"<u type='dashed' dash-width='4.0f'>ABC8</u>",
264 Text::Underline::DASHED,
276 //<u color='blue' type='dashed' height='4.0f' dash-gap='2.0f' dash-width='3.0f'>
277 {"<u color='blue' type='dashed' height='4.0f' dash-gap='2.0f' dash-width='3.0f'>",
283 Text::Underline::DASHED,
297 for(uint32_t i = 0; i < NUMBER_OF_CASES; i++)
299 tet_infoline(data[i].title.c_str());
300 DALI_TEST_EQUALS(underlineRuns[data[i].startIndex].glyphRun.glyphIndex, data[i].startGlyphIndex, TEST_LOCATION);
301 DALI_TEST_EQUALS(underlineRuns[data[i].endIndex].glyphRun.glyphIndex, data[i].endGlyphIndex, TEST_LOCATION);
303 DALI_TEST_CHECK(data[i].properties == underlineRuns[data[i].startIndex].properties);
304 DALI_TEST_CHECK(data[i].properties == underlineRuns[data[i].endIndex].properties);
310 int UtcDaliTextLabelBackgroundTag(void)
312 ToolkitTestApplication application;
313 tet_infoline("UtcDaliTextLabelBackgroundTag\n");
315 TextLabel label = TextLabel::New();
316 DALI_TEST_CHECK(label);
318 label.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
319 label.SetProperty(TextLabel::Property::TEXT, "H<background color='red'>e</background> Worl<background color='yellow'>d</background>");
320 application.GetScene().Add(label);
321 application.SendNotification();
322 application.Render();
324 Toolkit::Internal::TextLabel& labelImpl = GetImpl(label);
325 const ColorIndex* const backgroundColorIndicesBuffer = labelImpl.GetTextController()->GetTextModel()->GetBackgroundColorIndices();
327 DALI_TEST_CHECK(backgroundColorIndicesBuffer);
330 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[0], 0u, TEST_LOCATION);
333 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[1], 1u, TEST_LOCATION);
336 DALI_TEST_EQUALS(backgroundColorIndicesBuffer[7], 2u, TEST_LOCATION);
341 int UtcDaliToolkitTextlabelEllipsisInternalAPIs(void)
343 ToolkitTestApplication application;
344 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs ");
345 TextLabel textLabel = TextLabel::New();
347 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
348 const ModelInterface* const textModel = textLabelImpl.GetTextController()->GetTextModel();
350 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - ELLIPSIS Disabled");
351 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS, false);
352 DALI_TEST_EQUALS(textLabel.GetProperty<bool>(DevelTextLabel::Property::ELLIPSIS), false, TEST_LOCATION);
353 DALI_TEST_CHECK(!(textModel->IsTextElideEnabled()));
355 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - ELLIPSIS Enabled");
356 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS, true);
357 DALI_TEST_EQUALS(textLabel.GetProperty<bool>(DevelTextLabel::Property::ELLIPSIS), true, TEST_LOCATION);
358 DALI_TEST_CHECK(textModel->IsTextElideEnabled());
360 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetStartIndexOfElidedGlyphs Default");
361 DALI_TEST_EQUALS(textModel->GetStartIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
363 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetEndIndexOfElidedGlyphs Default");
364 DALI_TEST_EQUALS(textModel->GetEndIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
366 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetFirstMiddleIndexOfElidedGlyphs Default");
367 DALI_TEST_EQUALS(textModel->GetFirstMiddleIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
369 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetSecondMiddleIndexOfElidedGlyphs Default");
370 DALI_TEST_EQUALS(textModel->GetSecondMiddleIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
372 // Tests the rendering controller has been created.
373 TypesetterPtr typesetter = Typesetter::New(textModel);
374 DALI_TEST_CHECK(typesetter);
376 // Tests the view model has been created.
377 ViewModel* model = typesetter->GetViewModel();
379 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - IsTextElideEnabled ViewModel");
380 DALI_TEST_CHECK(model->IsTextElideEnabled());
382 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetStartIndexOfElidedGlyphs ViewModel");
383 DALI_TEST_EQUALS(model->GetStartIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
385 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetEndIndexOfElidedGlyphs ViewModel");
386 DALI_TEST_EQUALS(model->GetEndIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
388 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetFirstMiddleIndexOfElidedGlyphs ViewModel");
389 DALI_TEST_EQUALS(model->GetFirstMiddleIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
391 tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetSecondMiddleIndexOfElidedGlyphs ViewModel");
392 DALI_TEST_EQUALS(model->GetSecondMiddleIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
396 int UtcDaliTextLabelTextWithSpan(void)
398 ToolkitTestApplication application;
399 tet_infoline("UtcDaliTextLabelTextWithSpan\n");
401 TextLabel label = TextLabel::New();
402 DALI_TEST_CHECK(label);
404 label.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
405 label.SetProperty(TextLabel::Property::TEXT, "Hello Span");
406 application.GetScene().Add(label);
408 application.SendNotification();
409 application.Render();
411 Vector3 originalSize = label.GetNaturalSize();
412 label.SetProperty(TextLabel::Property::TEXT, "H<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red'>ello</span> Span");
414 application.SendNotification();
415 application.Render();
417 Vector3 spanSize = label.GetNaturalSize();
419 DALI_TEST_GREATER(spanSize.width, originalSize.width, TEST_LOCATION);
421 Toolkit::Internal::TextLabel& labelImpl = GetImpl(label);
422 const ColorIndex* const colorIndicesBuffer1 = labelImpl.GetTextController()->GetTextModel()->GetColorIndices();
424 DALI_TEST_CHECK(colorIndicesBuffer1);
427 DALI_TEST_EQUALS(colorIndicesBuffer1[0], 0u, TEST_LOCATION);
430 DALI_TEST_EQUALS(colorIndicesBuffer1[1], 1u, TEST_LOCATION);
433 DALI_TEST_EQUALS(colorIndicesBuffer1[6], 0u, TEST_LOCATION);
435 label.SetProperty(TextLabel::Property::TEXT, "<span font-size='45'>H</span>ello <span text-color='red'>S</span>pan");
437 application.SendNotification();
438 application.Render();
440 const ColorIndex* const colorIndicesBuffer2 = labelImpl.GetTextController()->GetTextModel()->GetColorIndices();
442 DALI_TEST_CHECK(colorIndicesBuffer2);
445 DALI_TEST_EQUALS(colorIndicesBuffer2[0], 0u, TEST_LOCATION);
448 DALI_TEST_EQUALS(colorIndicesBuffer2[1], 0u, TEST_LOCATION);
451 DALI_TEST_EQUALS(colorIndicesBuffer2[6], 1u, TEST_LOCATION);
454 DALI_TEST_EQUALS(colorIndicesBuffer2[7], 0u, TEST_LOCATION);
459 int UtcDaliTextLabelMarkupStrikethrough(void)
461 ToolkitTestApplication application;
462 tet_infoline(" UtcDaliTextLabelMarkupStrikethrough ");
464 TextLabel textLabel = TextLabel::New();
466 application.GetScene().Add(textLabel);
468 textLabel.SetProperty(TextLabel::Property::TEXT, "<s color='red'>ABC</s>EF<s color='green'>GH</s>");
469 textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
471 application.SendNotification();
472 application.Render();
474 uint32_t expectedNumberOfStrikethroughGlyphs = 2u;
476 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
477 const Text::Length numberOfStrikethroughRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns();
479 DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughGlyphs, TEST_LOCATION);
481 Vector<StrikethroughGlyphRun> strikethroughRuns;
482 strikethroughRuns.Resize(numberOfStrikethroughRuns);
483 textLabelImpl.GetTextController()->GetTextModel()->GetStrikethroughRuns(strikethroughRuns.Begin(), 0u, numberOfStrikethroughRuns);
485 //ABC have strikethrough
486 DALI_TEST_EQUALS(strikethroughRuns[0u].glyphRun.glyphIndex, 0u, TEST_LOCATION);
487 DALI_TEST_EQUALS(strikethroughRuns[0u].glyphRun.numberOfGlyphs, 3u, TEST_LOCATION);
488 DALI_TEST_CHECK(strikethroughRuns[0u].isColorSet);
489 DALI_TEST_EQUALS(strikethroughRuns[0u].color.r, 1u, TEST_LOCATION);
490 DALI_TEST_EQUALS(strikethroughRuns[0u].color.g, 0u, TEST_LOCATION);
491 DALI_TEST_EQUALS(strikethroughRuns[0u].color.b, 0u, TEST_LOCATION);
493 //GH have strikethrough
494 DALI_TEST_EQUALS(strikethroughRuns[1u].glyphRun.glyphIndex, 5u, TEST_LOCATION);
495 DALI_TEST_EQUALS(strikethroughRuns[1u].glyphRun.numberOfGlyphs, 2u, TEST_LOCATION);
496 DALI_TEST_CHECK(strikethroughRuns[1u].isColorSet);
497 DALI_TEST_EQUALS(strikethroughRuns[1u].color.r, 0u, TEST_LOCATION);
498 DALI_TEST_EQUALS(strikethroughRuns[1u].color.g, 1u, TEST_LOCATION);
499 DALI_TEST_EQUALS(strikethroughRuns[1u].color.b, 0u, TEST_LOCATION);
504 int UtcDaliTextLabelMarkupStrikethroughNoEndTag(void)
506 ToolkitTestApplication application;
507 tet_infoline(" UtcDaliTextLabelMarkupStrikethroughNoEndTag ");
509 TextLabel textLabel = TextLabel::New();
511 application.GetScene().Add(textLabel);
513 textLabel.SetProperty(TextLabel::Property::TEXT, "<s>ABC");
514 textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
516 application.SendNotification();
517 application.Render();
519 uint32_t expectedNumberOfStrikethroughGlyphs = 0u;
521 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
522 Text::Length numberOfStrikethroughRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns();
524 DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughGlyphs, TEST_LOCATION);
529 int UtcDaliTextLabelMarkupParagraphTag(void)
532 ToolkitTestApplication application;
534 tet_infoline(" UtcDaliTextLabelMarkupParagraphTag ");
535 TextLabel textLabel = TextLabel::New();
537 application.GetScene().Add(textLabel);
539 textLabel.SetProperty(TextLabel::Property::TEXT, "text one <p>Paragraph two</p> text three <p>Paragraph four</p> text five");
540 textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
541 textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
543 application.SendNotification();
544 application.Render();
546 uint32_t expectedNumberOfBoundedParagraphRuns = 2u;
548 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
549 const Text::Length numberOfBoundedParagraphRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfBoundedParagraphRuns();
550 DALI_TEST_EQUALS(numberOfBoundedParagraphRuns, expectedNumberOfBoundedParagraphRuns, TEST_LOCATION);
552 const Vector<BoundedParagraphRun>& boundedParagraphRuns = textLabelImpl.GetTextController()->GetTextModel()->GetBoundedParagraphRuns();
554 //<p>Paragraph two</p>
555 DALI_TEST_EQUALS(boundedParagraphRuns[0u].characterRun.characterIndex, 10u, TEST_LOCATION);
556 DALI_TEST_EQUALS(boundedParagraphRuns[0u].characterRun.numberOfCharacters, 14u, TEST_LOCATION);
558 //<p>Paragraph four</p>
559 DALI_TEST_EQUALS(boundedParagraphRuns[1u].characterRun.characterIndex, 37u, TEST_LOCATION);
560 DALI_TEST_EQUALS(boundedParagraphRuns[1u].characterRun.numberOfCharacters, 15u, TEST_LOCATION);
565 int UtcDaliTextLabelMarkupParagraphTagAlignAttribute(void)
567 ToolkitTestApplication application;
568 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute ");
570 // Apply alignment for each type on property level on three paragraphs and in-between text.
571 // Apply align in markup on the three paragraphs (each one a type).
572 // Using the same text to gain similar results from both the property level and the markup.
573 // Compare line alignment between the property level and the markup.
575 std::string textAlignOnPropertyLevel = "text outside<p>Paragraph end</p>text outside<p>Paragraph center</p>text outside<p>Paragraph begin</p><p>Paragraph property alignment</p>";
576 std::string textAlignInMarkup = "text outside<p align='end'>Paragraph end</p>text outside<p align='center'>Paragraph center</p>text outside<p align='begin' >Paragraph begin</p><p>Paragraph property alignment</p>";
578 //Set size to avoid automatic eliding
579 Vector2 controllerSize = Vector2(1025, 1025);
581 TextLabel textLabelBeginAlign = TextLabel::New();
582 TextLabel textLabelCenterAlign = TextLabel::New();
583 TextLabel textLabelEndAlign = TextLabel::New();
584 TextLabel textLabelMultiAlign = TextLabel::New();
586 application.GetScene().Add(textLabelBeginAlign);
587 application.GetScene().Add(textLabelCenterAlign);
588 application.GetScene().Add(textLabelEndAlign);
589 application.GetScene().Add(textLabelMultiAlign);
591 textLabelBeginAlign.SetProperty(TextLabel::Property::TEXT, textAlignOnPropertyLevel);
592 textLabelBeginAlign.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
593 textLabelBeginAlign.SetProperty(TextLabel::Property::MULTI_LINE, true);
594 textLabelBeginAlign.SetProperty(TextLabel::Property::ELLIPSIS, false);
595 textLabelBeginAlign.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::BEGIN);
596 textLabelBeginAlign.SetProperty(Actor::Property::SIZE, controllerSize);
598 textLabelCenterAlign.SetProperty(TextLabel::Property::TEXT, textAlignOnPropertyLevel);
599 textLabelCenterAlign.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
600 textLabelCenterAlign.SetProperty(TextLabel::Property::MULTI_LINE, true);
601 textLabelCenterAlign.SetProperty(TextLabel::Property::ELLIPSIS, false);
602 textLabelCenterAlign.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::CENTER);
603 textLabelCenterAlign.SetProperty(Actor::Property::SIZE, controllerSize);
605 textLabelEndAlign.SetProperty(TextLabel::Property::TEXT, textAlignOnPropertyLevel);
606 textLabelEndAlign.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
607 textLabelEndAlign.SetProperty(TextLabel::Property::MULTI_LINE, true);
608 textLabelEndAlign.SetProperty(TextLabel::Property::ELLIPSIS, false);
609 textLabelEndAlign.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::END);
610 textLabelEndAlign.SetProperty(Actor::Property::SIZE, controllerSize);
612 textLabelMultiAlign.SetProperty(TextLabel::Property::TEXT, textAlignInMarkup);
613 textLabelMultiAlign.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
614 textLabelMultiAlign.SetProperty(TextLabel::Property::MULTI_LINE, true);
615 textLabelMultiAlign.SetProperty(TextLabel::Property::ELLIPSIS, false);
616 textLabelMultiAlign.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::CENTER);
617 textLabelMultiAlign.SetProperty(Actor::Property::SIZE, controllerSize);
619 application.SendNotification();
620 application.Render();
622 uint32_t expectedNumberOfBoundedParagraphRuns = 4u;
623 uint32_t expectedNumberOfLines = 7u;
625 Toolkit::Internal::TextLabel& textLabelMultiAlignImpl = GetImpl(textLabelMultiAlign);
626 Toolkit::Internal::TextLabel& textLabelBeginAlignImpl = GetImpl(textLabelBeginAlign);
627 Toolkit::Internal::TextLabel& textLabelCenterAlignImpl = GetImpl(textLabelCenterAlign);
628 Toolkit::Internal::TextLabel& textLabelEndAlignImpl = GetImpl(textLabelEndAlign);
630 const Text::Length numberOfBoundedParagraphRuns = textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetNumberOfBoundedParagraphRuns();
631 DALI_TEST_EQUALS(numberOfBoundedParagraphRuns, expectedNumberOfBoundedParagraphRuns, TEST_LOCATION);
633 DALI_TEST_EQUALS(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
634 DALI_TEST_CHECK(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines());
636 DALI_TEST_EQUALS(textLabelBeginAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
637 DALI_TEST_CHECK(textLabelBeginAlignImpl.GetTextController()->GetTextModel()->GetLines());
639 DALI_TEST_EQUALS(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
640 DALI_TEST_CHECK(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines());
642 DALI_TEST_EQUALS(textLabelEndAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
643 DALI_TEST_CHECK(textLabelEndAlignImpl.GetTextController()->GetTextModel()->GetLines());
645 const uint32_t LINE_INDEX_ALIGN_END = 1u;
646 const uint32_t LINE_INDEX_ALIGN_CENTER = 3u;
647 const uint32_t LINE_INDEX_ALIGN_BEGIN = 5u;
648 const uint32_t LINE_INDEX_OUTSIDE_1 = 0u;
649 const uint32_t LINE_INDEX_OUTSIDE_2 = 2u;
650 const uint32_t LINE_INDEX_OUTSIDE_3 = 4u;
651 const uint32_t LINE_INDEX_PARAGRAPH = 6u;
653 //<p align='end'>Paragraph end</p>
654 const LineRun& lineEndFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_END);
655 const LineRun& lineEndFromEndAlign = *(textLabelEndAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_END);
656 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - <p align='end'>Paragraph end</p>");
657 DALI_TEST_EQUALS(lineEndFromMultiAlign.alignmentOffset, lineEndFromEndAlign.alignmentOffset, TEST_LOCATION);
658 DALI_TEST_EQUALS(lineEndFromMultiAlign.width, lineEndFromEndAlign.width, TEST_LOCATION);
660 //<p align='center'>Paragraph center</p>
661 const LineRun& lineCenterFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_CENTER);
662 const LineRun& lineEndFromCenterAlign = *(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_CENTER);
663 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - <p align='center'>Paragraph center</p>");
664 DALI_TEST_EQUALS(lineCenterFromMultiAlign.alignmentOffset, lineEndFromCenterAlign.alignmentOffset, TEST_LOCATION);
665 DALI_TEST_EQUALS(lineCenterFromMultiAlign.width, lineEndFromCenterAlign.width, TEST_LOCATION);
667 //<p align='begin' >Paragraph begin</p>
668 const LineRun& lineBeginFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_BEGIN);
669 const LineRun& lineEndFromBeginAlign = *(textLabelBeginAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_BEGIN);
670 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - <p align='begin' >Paragraph begin</p>");
671 DALI_TEST_EQUALS(lineBeginFromMultiAlign.alignmentOffset, lineEndFromBeginAlign.alignmentOffset, TEST_LOCATION);
672 DALI_TEST_EQUALS(lineBeginFromMultiAlign.width, lineEndFromBeginAlign.width, TEST_LOCATION);
675 const LineRun& lineOutsideOneFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_1);
676 const LineRun& lineOutsideOneFromCenterAlign = *(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_1);
677 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - text outside one");
678 DALI_TEST_EQUALS(lineOutsideOneFromMultiAlign.alignmentOffset, lineOutsideOneFromCenterAlign.alignmentOffset, TEST_LOCATION);
679 DALI_TEST_EQUALS(lineOutsideOneFromMultiAlign.width, lineOutsideOneFromCenterAlign.width, TEST_LOCATION);
681 const LineRun& lineOutsideTwoFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_2);
682 const LineRun& lineOutsideTwoFromCenterAlign = *(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_2);
683 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - text outside two");
684 DALI_TEST_EQUALS(lineOutsideTwoFromMultiAlign.alignmentOffset, lineOutsideTwoFromCenterAlign.alignmentOffset, TEST_LOCATION);
685 DALI_TEST_EQUALS(lineOutsideTwoFromMultiAlign.width, lineOutsideTwoFromCenterAlign.width, TEST_LOCATION);
687 const LineRun& lineOutsideThreeFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_3);
688 const LineRun& lineOutsideThreeFromCenterAlign = *(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_3);
689 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - text outside three");
690 DALI_TEST_EQUALS(lineOutsideThreeFromMultiAlign.alignmentOffset, lineOutsideThreeFromCenterAlign.alignmentOffset, TEST_LOCATION);
691 DALI_TEST_EQUALS(lineOutsideThreeFromMultiAlign.width, lineOutsideThreeFromCenterAlign.width, TEST_LOCATION);
693 const LineRun& lineParagraphFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_PARAGRAPH);
694 const LineRun& lineParagraphFromCenterAlign = *(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_PARAGRAPH);
695 tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - <p>Paragraph property alignment</p>");
696 DALI_TEST_EQUALS(lineParagraphFromMultiAlign.alignmentOffset, lineParagraphFromCenterAlign.alignmentOffset, TEST_LOCATION);
697 DALI_TEST_EQUALS(lineParagraphFromMultiAlign.width, lineParagraphFromCenterAlign.width, TEST_LOCATION);