4259cdcd07562031b752d42f131d4beda00c5a60
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-internal / utc-Dali-TextLabel-internal.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <stdlib.h>
19 #include <iostream>
20
21 #include <dali-toolkit-test-suite-utils.h>
22 #include <dali-toolkit/dali-toolkit.h>
23
24 #include <dali-toolkit/internal/controls/text-controls/text-label-impl.h>
25 #include <dali-toolkit/internal/text/rendering/text-typesetter.h>
26 #include <dali-toolkit/internal/text/rendering/view-model.h>
27 #include <dali-toolkit/internal/text/text-controller-impl.h>
28 #include <dali-toolkit/internal/text/text-controller.h>
29
30 using namespace Dali;
31 using namespace Toolkit;
32 using namespace Text;
33
34 int UtcDaliTextLabelMarkupUnderline(void)
35 {
36   ToolkitTestApplication application;
37   tet_infoline(" UtcDaliTextLabelMarkupUnderline ");
38
39   TextLabel textLabel = TextLabel::New();
40
41   application.GetScene().Add(textLabel);
42
43   textLabel.SetProperty(TextLabel::Property::TEXT, "<u>ABC</u>EF<u>GH</u>");
44   textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
45
46   application.SendNotification();
47   application.Render();
48
49   uint32_t expectedNumberOfUnderlinedGlyphs = 5u;
50
51   Toolkit::Internal::TextLabel& textLabelImpl         = GetImpl(textLabel);
52   const Text::Length            numberOfUnderlineRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns();
53
54   DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlinedGlyphs, TEST_LOCATION);
55
56   Vector<UnderlinedGlyphRun> underlineRuns;
57   underlineRuns.Resize(numberOfUnderlineRuns);
58   textLabelImpl.GetTextController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns);
59
60   //ABC are underlined
61   DALI_TEST_EQUALS(underlineRuns[0u].glyphRun.glyphIndex, 0u, TEST_LOCATION);
62   DALI_TEST_EQUALS(underlineRuns[1u].glyphRun.glyphIndex, 1u, TEST_LOCATION);
63   DALI_TEST_EQUALS(underlineRuns[2u].glyphRun.glyphIndex, 2u, TEST_LOCATION);
64
65   //GH are underlined
66   DALI_TEST_EQUALS(underlineRuns[3u].glyphRun.glyphIndex, 5u, TEST_LOCATION);
67   DALI_TEST_EQUALS(underlineRuns[4u].glyphRun.glyphIndex, 6u, TEST_LOCATION);
68
69   END_TEST;
70 }
71
72 int UtcDaliTextLabelMarkupUnderlineAttributes(void)
73 {
74   ToolkitTestApplication application;
75   tet_infoline(" UtcDaliTextLabelMarkupUnderlineAttributes ");
76
77   TextLabel textLabel = TextLabel::New();
78
79   application.GetScene().Add(textLabel);
80
81   std::string testText =
82     "start<u>ABC1</u>then"
83     "<u type='solid'>ABC2</u>then"
84     "<u type='dashed'>ABC3</u>then"
85     "<u type='double'>ABC4</u>then"
86     "<u color='green'>ABC5</u>then"
87     "<u height='5.0f'>ABC6</u>then"
88     "<u type='dashed' dash-gap='3.0f'>ABC7</u>then"
89     "<u type='dashed' dash-width='4.0f'>ABC8</u>then"
90     "<u color='blue' type='dashed' height='4.0f' dash-gap='2.0f' dash-width='3.0f'>ABC9</u>end"
91
92     ;
93
94   textLabel.SetProperty(TextLabel::Property::TEXT, testText);
95   textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
96
97   application.SendNotification();
98   application.Render();
99
100   const uint32_t NUMBER_OF_CASES                  = 9u;
101   uint32_t       expectedNumberOfUnderlinedGlyphs = 36u;
102
103   Toolkit::Internal::TextLabel& textLabelImpl         = GetImpl(textLabel);
104   const Text::Length            numberOfUnderlineRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns();
105
106   DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlinedGlyphs, TEST_LOCATION);
107
108   Vector<UnderlinedGlyphRun> underlineRuns;
109   underlineRuns.Resize(numberOfUnderlineRuns);
110   textLabelImpl.GetTextController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns);
111
112   struct DataOfCase
113   {
114     std::string              title;
115     uint32_t                 startIndex;
116     uint32_t                 endIndex;
117     GlyphIndex               startGlyphIndex;
118     GlyphIndex               endGlyphIndex;
119     UnderlineStyleProperties properties;
120   };
121   DataOfCase data[] =
122     {
123       //<u>ABC1</u>
124       {"<u>ABC1</u>",
125        0u,
126        3u,
127        5u,
128        8u,
129        {
130          Text::Underline::SOLID,
131          Color::BLACK,
132          0u,
133          1u,
134          2u,
135          false,
136          false,
137          false,
138          false,
139          false,
140        }},
141
142       //<u type='solid'>ABC2</u>
143       {"<u type='solid'>ABC2</u>",
144        4u,
145        7u,
146        13u,
147        16u,
148        {
149          Text::Underline::SOLID,
150          Color::BLACK,
151          0u,
152          1u,
153          2u,
154          true,
155          false,
156          false,
157          false,
158          false,
159        }},
160
161       //<u type='dashed'>ABC3</u>
162       {"<u type='dashed'>ABC3</u>",
163        8u,
164        11u,
165        21u,
166        24u,
167        {
168          Text::Underline::DASHED,
169          Color::BLACK,
170          0u,
171          1u,
172          2u,
173          true,
174          false,
175          false,
176          false,
177          false,
178        }},
179
180       //<u type='double'>ABC4</u>
181       {"<u type='double'>ABC4</u>",
182        12u,
183        15u,
184        29u,
185        32u,
186        {
187          Text::Underline::DOUBLE,
188          Color::BLACK,
189          0u,
190          1u,
191          2u,
192          true,
193          false,
194          false,
195          false,
196          false,
197        }},
198
199       //<u color='green'>ABC5</u>
200       {"<u color='green'>ABC5</u>",
201        16u,
202        19u,
203        37u,
204        40u,
205        {
206          Text::Underline::SOLID,
207          Color::GREEN,
208          0u,
209          1u,
210          2u,
211          false,
212          true,
213          false,
214          false,
215          false,
216        }},
217
218       //<u height='5.0f'>ABC6</u>
219       {"<u height='5.0f'>ABC6</u>",
220        20u,
221        23u,
222        45u,
223        48u,
224        {
225          Text::Underline::SOLID,
226          Color::BLACK,
227          5u,
228          1u,
229          2u,
230          false,
231          false,
232          true,
233          false,
234          false,
235        }},
236
237       //<u type='dashed' dash-gap='3.0f'>ABC7</u>
238       {"<u type='dashed' dash-gap='3.0f'>ABC7</u>",
239        24u,
240        27u,
241        53u,
242        56u,
243        {
244          Text::Underline::DASHED,
245          Color::BLACK,
246          0u,
247          3u,
248          2u,
249          true,
250          false,
251          false,
252          true,
253          false,
254        }},
255
256       //<u type='dashed' dash-width='4.0f'>ABC8</u>
257       {"<u type='dashed' dash-width='4.0f'>ABC8</u>",
258        28u,
259        31u,
260        61u,
261        64u,
262        {
263          Text::Underline::DASHED,
264          Color::BLACK,
265          0u,
266          1u,
267          4u,
268          true,
269          false,
270          false,
271          false,
272          true,
273        }},
274
275       //<u color='blue' type='dashed' height='4.0f' dash-gap='2.0f' dash-width='3.0f'>
276       {"<u color='blue' type='dashed' height='4.0f' dash-gap='2.0f' dash-width='3.0f'>",
277        32u,
278        35u,
279        69u,
280        72u,
281        {
282          Text::Underline::DASHED,
283          Color::BLUE,
284          4u,
285          2u,
286          3u,
287          true,
288          true,
289          true,
290          true,
291          true,
292        }},
293
294     };
295
296   for(uint32_t i = 0; i < NUMBER_OF_CASES; i++)
297   {
298     tet_infoline(data[i].title.c_str());
299     DALI_TEST_EQUALS(underlineRuns[data[i].startIndex].glyphRun.glyphIndex, data[i].startGlyphIndex, TEST_LOCATION);
300     DALI_TEST_EQUALS(underlineRuns[data[i].endIndex].glyphRun.glyphIndex, data[i].endGlyphIndex, TEST_LOCATION);
301
302     DALI_TEST_CHECK(data[i].properties == underlineRuns[data[i].startIndex].properties);
303     DALI_TEST_CHECK(data[i].properties == underlineRuns[data[i].endIndex].properties);
304   }
305
306   END_TEST;
307 }
308
309 int UtcDaliTextLabelBackgroundTag(void)
310 {
311   ToolkitTestApplication application;
312   tet_infoline("UtcDaliTextLabelBackgroundTag\n");
313
314   TextLabel label = TextLabel::New();
315   DALI_TEST_CHECK(label);
316
317   label.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
318   label.SetProperty(TextLabel::Property::TEXT, "H<background color='red'>e</background> Worl<background color='yellow'>d</background>");
319   application.GetScene().Add(label);
320   application.SendNotification();
321   application.Render();
322
323   Toolkit::Internal::TextLabel& labelImpl                    = GetImpl(label);
324   const ColorIndex* const       backgroundColorIndicesBuffer = labelImpl.GetTextController()->GetTextModel()->GetBackgroundColorIndices();
325
326   DALI_TEST_CHECK(backgroundColorIndicesBuffer);
327
328   //default color
329   DALI_TEST_EQUALS(backgroundColorIndicesBuffer[0], 0u, TEST_LOCATION);
330
331   //red color
332   DALI_TEST_EQUALS(backgroundColorIndicesBuffer[1], 1u, TEST_LOCATION);
333
334   //yellow color
335   DALI_TEST_EQUALS(backgroundColorIndicesBuffer[7], 2u, TEST_LOCATION);
336
337   END_TEST;
338 }
339
340 int UtcDaliToolkitTextlabelEllipsisInternalAPIs(void)
341 {
342   ToolkitTestApplication application;
343   tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs ");
344   TextLabel textLabel = TextLabel::New();
345
346   Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
347   const ModelInterface* const   textModel     = textLabelImpl.GetTextController()->GetTextModel();
348
349   tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - ELLIPSIS Disabled");
350   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS, false);
351   DALI_TEST_EQUALS(textLabel.GetProperty<bool>(DevelTextLabel::Property::ELLIPSIS), false, TEST_LOCATION);
352   DALI_TEST_CHECK(!(textModel->IsTextElideEnabled()));
353
354   tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - ELLIPSIS Enabled");
355   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS, true);
356   DALI_TEST_EQUALS(textLabel.GetProperty<bool>(DevelTextLabel::Property::ELLIPSIS), true, TEST_LOCATION);
357   DALI_TEST_CHECK(textModel->IsTextElideEnabled());
358
359   tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetStartIndexOfElidedGlyphs Default");
360   DALI_TEST_EQUALS(textModel->GetStartIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
361
362   tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetEndIndexOfElidedGlyphs Default");
363   DALI_TEST_EQUALS(textModel->GetEndIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
364
365   tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetFirstMiddleIndexOfElidedGlyphs Default");
366   DALI_TEST_EQUALS(textModel->GetFirstMiddleIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
367
368   tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetSecondMiddleIndexOfElidedGlyphs Default");
369   DALI_TEST_EQUALS(textModel->GetSecondMiddleIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
370
371   // Tests the rendering controller has been created.
372   TypesetterPtr typesetter = Typesetter::New(textModel);
373   DALI_TEST_CHECK(typesetter);
374
375   // Tests the view model has been created.
376   ViewModel* model = typesetter->GetViewModel();
377
378   tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - IsTextElideEnabled ViewModel");
379   DALI_TEST_CHECK(model->IsTextElideEnabled());
380
381   tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetStartIndexOfElidedGlyphs ViewModel");
382   DALI_TEST_EQUALS(model->GetStartIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
383
384   tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetEndIndexOfElidedGlyphs ViewModel");
385   DALI_TEST_EQUALS(model->GetEndIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
386
387   tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetFirstMiddleIndexOfElidedGlyphs ViewModel");
388   DALI_TEST_EQUALS(model->GetFirstMiddleIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
389
390   tet_infoline(" UtcDaliToolkitTextlabelEllipsisInternalAPIs - GetSecondMiddleIndexOfElidedGlyphs ViewModel");
391   DALI_TEST_EQUALS(model->GetSecondMiddleIndexOfElidedGlyphs(), 0u, TEST_LOCATION);
392
393   END_TEST;
394 }
395 int UtcDaliTextLabelTextWithSpan(void)
396 {
397   ToolkitTestApplication application;
398   tet_infoline("UtcDaliTextLabelTextWithSpan\n");
399
400   TextLabel label = TextLabel::New();
401   DALI_TEST_CHECK(label);
402
403   label.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
404   label.SetProperty(TextLabel::Property::TEXT, "Hello Span");
405   application.GetScene().Add(label);
406
407   application.SendNotification();
408   application.Render();
409
410   Vector3 originalSize = label.GetNaturalSize();
411   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");
412
413   application.SendNotification();
414   application.Render();
415
416   Vector3 spanSize = label.GetNaturalSize();
417
418   DALI_TEST_GREATER(spanSize.width, originalSize.width, TEST_LOCATION);
419
420   Toolkit::Internal::TextLabel& labelImpl           = GetImpl(label);
421   const ColorIndex* const       colorIndicesBuffer1 = labelImpl.GetTextController()->GetTextModel()->GetColorIndices();
422
423   DALI_TEST_CHECK(colorIndicesBuffer1);
424
425   //default color
426   DALI_TEST_EQUALS(colorIndicesBuffer1[0], 0u, TEST_LOCATION);
427
428   //span color
429   DALI_TEST_EQUALS(colorIndicesBuffer1[1], 1u, TEST_LOCATION);
430
431   //default color
432   DALI_TEST_EQUALS(colorIndicesBuffer1[6], 0u, TEST_LOCATION);
433
434   label.SetProperty(TextLabel::Property::TEXT, "<span font-size='45'>H</span>ello <span text-color='red'>S</span>pan");
435
436   application.SendNotification();
437   application.Render();
438
439   const ColorIndex* const colorIndicesBuffer2 = labelImpl.GetTextController()->GetTextModel()->GetColorIndices();
440
441   DALI_TEST_CHECK(colorIndicesBuffer2);
442
443   //default color
444   DALI_TEST_EQUALS(colorIndicesBuffer2[0], 0u, TEST_LOCATION);
445
446   //default color
447   DALI_TEST_EQUALS(colorIndicesBuffer2[1], 0u, TEST_LOCATION);
448
449   //span color
450   DALI_TEST_EQUALS(colorIndicesBuffer2[6], 1u, TEST_LOCATION);
451
452   //default color
453   DALI_TEST_EQUALS(colorIndicesBuffer2[7], 0u, TEST_LOCATION);
454
455   END_TEST;
456 }
457
458 int UtcDaliTextLabelMarkupStrikethrough(void)
459 {
460   ToolkitTestApplication application;
461   tet_infoline(" UtcDaliTextLabelMarkupStrikethrough ");
462
463   TextLabel textLabel = TextLabel::New();
464
465   application.GetScene().Add(textLabel);
466
467   textLabel.SetProperty(TextLabel::Property::TEXT, "<s color='red'>ABC</s>EF<s color='green'>GH</s>");
468   textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
469
470   application.SendNotification();
471   application.Render();
472
473   uint32_t expectedNumberOfStrikethroughGlyphs = 2u;
474
475   Toolkit::Internal::TextLabel& textLabelImpl             = GetImpl(textLabel);
476   const Text::Length            numberOfStrikethroughRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns();
477
478   DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughGlyphs, TEST_LOCATION);
479
480   Vector<StrikethroughGlyphRun> strikethroughRuns;
481   strikethroughRuns.Resize(numberOfStrikethroughRuns);
482   textLabelImpl.GetTextController()->GetTextModel()->GetStrikethroughRuns(strikethroughRuns.Begin(), 0u, numberOfStrikethroughRuns);
483
484   //ABC have strikethrough
485   DALI_TEST_EQUALS(strikethroughRuns[0u].glyphRun.glyphIndex, 0u, TEST_LOCATION);
486   DALI_TEST_EQUALS(strikethroughRuns[0u].glyphRun.numberOfGlyphs, 3u, TEST_LOCATION);
487   DALI_TEST_CHECK(strikethroughRuns[0u].isColorSet);
488   DALI_TEST_EQUALS(strikethroughRuns[0u].color.r, 1u, TEST_LOCATION);
489   DALI_TEST_EQUALS(strikethroughRuns[0u].color.g, 0u, TEST_LOCATION);
490   DALI_TEST_EQUALS(strikethroughRuns[0u].color.b, 0u, TEST_LOCATION);
491
492   //GH have strikethrough
493   DALI_TEST_EQUALS(strikethroughRuns[1u].glyphRun.glyphIndex, 5u, TEST_LOCATION);
494   DALI_TEST_EQUALS(strikethroughRuns[1u].glyphRun.numberOfGlyphs, 2u, TEST_LOCATION);
495   DALI_TEST_CHECK(strikethroughRuns[1u].isColorSet);
496   DALI_TEST_EQUALS(strikethroughRuns[1u].color.r, 0u, TEST_LOCATION);
497   DALI_TEST_EQUALS(strikethroughRuns[1u].color.g, 1u, TEST_LOCATION);
498   DALI_TEST_EQUALS(strikethroughRuns[1u].color.b, 0u, TEST_LOCATION);
499
500   END_TEST;
501 }
502
503 int UtcDaliTextLabelMarkupStrikethroughNoEndTag(void)
504 {
505   ToolkitTestApplication application;
506   tet_infoline(" UtcDaliTextLabelMarkupStrikethroughNoEndTag ");
507
508   TextLabel textLabel = TextLabel::New();
509
510   application.GetScene().Add(textLabel);
511
512   textLabel.SetProperty(TextLabel::Property::TEXT, "<s>ABC");
513   textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
514
515   application.SendNotification();
516   application.Render();
517
518   uint32_t expectedNumberOfStrikethroughGlyphs = 0u;
519
520   Toolkit::Internal::TextLabel& textLabelImpl             = GetImpl(textLabel);
521   Text::Length                  numberOfStrikethroughRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns();
522
523   DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughGlyphs, TEST_LOCATION);
524
525   END_TEST;
526 }
527
528 int UtcDaliTextLabelMarkupParagraphTag(void)
529
530 {
531   ToolkitTestApplication application;
532
533   tet_infoline(" UtcDaliTextLabelMarkupParagraphTag ");
534   TextLabel textLabel = TextLabel::New();
535
536   application.GetScene().Add(textLabel);
537
538   textLabel.SetProperty(TextLabel::Property::TEXT, "text one <p>Paragraph two</p> text three <p>Paragraph four</p> text five");
539   textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
540   textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
541
542   application.SendNotification();
543   application.Render();
544
545   uint32_t expectedNumberOfBoundedParagraphRuns = 2u;
546
547   Toolkit::Internal::TextLabel& textLabelImpl                = GetImpl(textLabel);
548   const Text::Length            numberOfBoundedParagraphRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfBoundedParagraphRuns();
549   DALI_TEST_EQUALS(numberOfBoundedParagraphRuns, expectedNumberOfBoundedParagraphRuns, TEST_LOCATION);
550
551   const Vector<BoundedParagraphRun>& boundedParagraphRuns = textLabelImpl.GetTextController()->GetTextModel()->GetBoundedParagraphRuns();
552
553   //<p>Paragraph two</p>
554   DALI_TEST_EQUALS(boundedParagraphRuns[0u].characterRun.characterIndex, 10u, TEST_LOCATION);
555   DALI_TEST_EQUALS(boundedParagraphRuns[0u].characterRun.numberOfCharacters, 14u, TEST_LOCATION);
556
557   //<p>Paragraph four</p>
558   DALI_TEST_EQUALS(boundedParagraphRuns[1u].characterRun.characterIndex, 37u, TEST_LOCATION);
559   DALI_TEST_EQUALS(boundedParagraphRuns[1u].characterRun.numberOfCharacters, 15u, TEST_LOCATION);
560
561   END_TEST;
562 }
563
564 int UtcDaliTextLabelMarkupParagraphTagAlignAttribute(void)
565 {
566   ToolkitTestApplication application;
567   tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute ");
568
569   // Apply alignment for each type on property level on three paragraphs and in-between text.
570   // Apply align in markup on the three paragraphs (each one a type).
571   // Using the same text to gain similar results from both the property level and the markup.
572   // Compare line alignment between the property level and the markup.
573
574   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>";
575   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>";
576
577   //Set size to avoid automatic eliding
578   Vector2 controllerSize = Vector2(1025, 1025);
579
580   TextLabel textLabelBeginAlign  = TextLabel::New();
581   TextLabel textLabelCenterAlign = TextLabel::New();
582   TextLabel textLabelEndAlign    = TextLabel::New();
583   TextLabel textLabelMultiAlign  = TextLabel::New();
584
585   application.GetScene().Add(textLabelBeginAlign);
586   application.GetScene().Add(textLabelCenterAlign);
587   application.GetScene().Add(textLabelEndAlign);
588   application.GetScene().Add(textLabelMultiAlign);
589
590   textLabelBeginAlign.SetProperty(TextLabel::Property::TEXT, textAlignOnPropertyLevel);
591   textLabelBeginAlign.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
592   textLabelBeginAlign.SetProperty(TextLabel::Property::MULTI_LINE, true);
593   textLabelBeginAlign.SetProperty(TextLabel::Property::ELLIPSIS, false);
594   textLabelBeginAlign.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::BEGIN);
595   textLabelBeginAlign.SetProperty(Actor::Property::SIZE, controllerSize);
596
597   textLabelCenterAlign.SetProperty(TextLabel::Property::TEXT, textAlignOnPropertyLevel);
598   textLabelCenterAlign.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
599   textLabelCenterAlign.SetProperty(TextLabel::Property::MULTI_LINE, true);
600   textLabelCenterAlign.SetProperty(TextLabel::Property::ELLIPSIS, false);
601   textLabelCenterAlign.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::CENTER);
602   textLabelCenterAlign.SetProperty(Actor::Property::SIZE, controllerSize);
603
604   textLabelEndAlign.SetProperty(TextLabel::Property::TEXT, textAlignOnPropertyLevel);
605   textLabelEndAlign.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
606   textLabelEndAlign.SetProperty(TextLabel::Property::MULTI_LINE, true);
607   textLabelEndAlign.SetProperty(TextLabel::Property::ELLIPSIS, false);
608   textLabelEndAlign.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::END);
609   textLabelEndAlign.SetProperty(Actor::Property::SIZE, controllerSize);
610
611   textLabelMultiAlign.SetProperty(TextLabel::Property::TEXT, textAlignInMarkup);
612   textLabelMultiAlign.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
613   textLabelMultiAlign.SetProperty(TextLabel::Property::MULTI_LINE, true);
614   textLabelMultiAlign.SetProperty(TextLabel::Property::ELLIPSIS, false);
615   textLabelMultiAlign.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, Dali::Toolkit::Text::HorizontalAlignment::CENTER);
616   textLabelMultiAlign.SetProperty(Actor::Property::SIZE, controllerSize);
617
618   application.SendNotification();
619   application.Render();
620
621   uint32_t expectedNumberOfBoundedParagraphRuns = 4u;
622   uint32_t expectedNumberOfLines                = 7u;
623
624   Toolkit::Internal::TextLabel& textLabelMultiAlignImpl  = GetImpl(textLabelMultiAlign);
625   Toolkit::Internal::TextLabel& textLabelBeginAlignImpl  = GetImpl(textLabelBeginAlign);
626   Toolkit::Internal::TextLabel& textLabelCenterAlignImpl = GetImpl(textLabelCenterAlign);
627   Toolkit::Internal::TextLabel& textLabelEndAlignImpl    = GetImpl(textLabelEndAlign);
628
629   const Text::Length numberOfBoundedParagraphRuns = textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetNumberOfBoundedParagraphRuns();
630   DALI_TEST_EQUALS(numberOfBoundedParagraphRuns, expectedNumberOfBoundedParagraphRuns, TEST_LOCATION);
631
632   DALI_TEST_EQUALS(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
633   DALI_TEST_CHECK(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines());
634
635   DALI_TEST_EQUALS(textLabelBeginAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
636   DALI_TEST_CHECK(textLabelBeginAlignImpl.GetTextController()->GetTextModel()->GetLines());
637
638   DALI_TEST_EQUALS(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
639   DALI_TEST_CHECK(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines());
640
641   DALI_TEST_EQUALS(textLabelEndAlignImpl.GetTextController()->GetTextModel()->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
642   DALI_TEST_CHECK(textLabelEndAlignImpl.GetTextController()->GetTextModel()->GetLines());
643
644   const uint32_t LINE_INDEX_ALIGN_END    = 1u;
645   const uint32_t LINE_INDEX_ALIGN_CENTER = 3u;
646   const uint32_t LINE_INDEX_ALIGN_BEGIN  = 5u;
647   const uint32_t LINE_INDEX_OUTSIDE_1    = 0u;
648   const uint32_t LINE_INDEX_OUTSIDE_2    = 2u;
649   const uint32_t LINE_INDEX_OUTSIDE_3    = 4u;
650   const uint32_t LINE_INDEX_PARAGRAPH    = 6u;
651
652   //<p align='end'>Paragraph end</p>
653   const LineRun& lineEndFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_END);
654   const LineRun& lineEndFromEndAlign   = *(textLabelEndAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_END);
655   tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - <p align='end'>Paragraph end</p>");
656   DALI_TEST_EQUALS(lineEndFromMultiAlign.alignmentOffset, lineEndFromEndAlign.alignmentOffset, TEST_LOCATION);
657   DALI_TEST_EQUALS(lineEndFromMultiAlign.width, lineEndFromEndAlign.width, TEST_LOCATION);
658
659   //<p align='center'>Paragraph center</p>
660   const LineRun& lineCenterFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_CENTER);
661   const LineRun& lineEndFromCenterAlign   = *(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_CENTER);
662   tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - <p align='center'>Paragraph center</p>");
663   DALI_TEST_EQUALS(lineCenterFromMultiAlign.alignmentOffset, lineEndFromCenterAlign.alignmentOffset, TEST_LOCATION);
664   DALI_TEST_EQUALS(lineCenterFromMultiAlign.width, lineEndFromCenterAlign.width, TEST_LOCATION);
665
666   //<p align='begin' >Paragraph begin</p>
667   const LineRun& lineBeginFromMultiAlign = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_BEGIN);
668   const LineRun& lineEndFromBeginAlign   = *(textLabelBeginAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_ALIGN_BEGIN);
669   tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - <p align='begin' >Paragraph begin</p>");
670   DALI_TEST_EQUALS(lineBeginFromMultiAlign.alignmentOffset, lineEndFromBeginAlign.alignmentOffset, TEST_LOCATION);
671   DALI_TEST_EQUALS(lineBeginFromMultiAlign.width, lineEndFromBeginAlign.width, TEST_LOCATION);
672
673   //text outside
674   const LineRun& lineOutsideOneFromMultiAlign  = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_1);
675   const LineRun& lineOutsideOneFromCenterAlign = *(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_1);
676   tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - text outside one");
677   DALI_TEST_EQUALS(lineOutsideOneFromMultiAlign.alignmentOffset, lineOutsideOneFromCenterAlign.alignmentOffset, TEST_LOCATION);
678   DALI_TEST_EQUALS(lineOutsideOneFromMultiAlign.width, lineOutsideOneFromCenterAlign.width, TEST_LOCATION);
679
680   const LineRun& lineOutsideTwoFromMultiAlign  = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_2);
681   const LineRun& lineOutsideTwoFromCenterAlign = *(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_2);
682   tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - text outside two");
683   DALI_TEST_EQUALS(lineOutsideTwoFromMultiAlign.alignmentOffset, lineOutsideTwoFromCenterAlign.alignmentOffset, TEST_LOCATION);
684   DALI_TEST_EQUALS(lineOutsideTwoFromMultiAlign.width, lineOutsideTwoFromCenterAlign.width, TEST_LOCATION);
685
686   const LineRun& lineOutsideThreeFromMultiAlign  = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_3);
687   const LineRun& lineOutsideThreeFromCenterAlign = *(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_OUTSIDE_3);
688   tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - text outside three");
689   DALI_TEST_EQUALS(lineOutsideThreeFromMultiAlign.alignmentOffset, lineOutsideThreeFromCenterAlign.alignmentOffset, TEST_LOCATION);
690   DALI_TEST_EQUALS(lineOutsideThreeFromMultiAlign.width, lineOutsideThreeFromCenterAlign.width, TEST_LOCATION);
691
692   const LineRun& lineParagraphFromMultiAlign  = *(textLabelMultiAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_PARAGRAPH);
693   const LineRun& lineParagraphFromCenterAlign = *(textLabelCenterAlignImpl.GetTextController()->GetTextModel()->GetLines() + LINE_INDEX_PARAGRAPH);
694   tet_infoline(" UtcDaliTextLabelMarkupParagraphTagAlignAttribute - <p>Paragraph property alignment</p>");
695   DALI_TEST_EQUALS(lineParagraphFromMultiAlign.alignmentOffset, lineParagraphFromCenterAlign.alignmentOffset, TEST_LOCATION);
696   DALI_TEST_EQUALS(lineParagraphFromMultiAlign.width, lineParagraphFromCenterAlign.width, TEST_LOCATION);
697
698   END_TEST;
699 }