[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-internal / utc-Dali-Text-TextSpannable.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 <unistd.h>
20 #include <iostream>
21
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-spannable.h>
25 #include <dali-toolkit/devel-api/text/spannable-string.h>
26 #include <dali-toolkit/devel-api/text/spans/background-color-span.h>
27 #include <dali-toolkit/devel-api/text/spans/bold-span.h>
28 #include <dali-toolkit/devel-api/text/spans/character-spacing-span.h>
29 #include <dali-toolkit/devel-api/text/spans/font-span.h>
30 #include <dali-toolkit/devel-api/text/spans/foreground-color-span.h>
31 #include <dali-toolkit/devel-api/text/spans/italic-span.h>
32 #include <dali-toolkit/devel-api/text/spans/strikethrough-span.h>
33 #include <dali-toolkit/devel-api/text/spans/underline-span.h>
34 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
35 #include <dali-toolkit/internal/controls/text-controls/text-editor-impl.h>
36 #include <dali-toolkit/internal/controls/text-controls/text-field-impl.h>
37 #include <dali-toolkit/internal/controls/text-controls/text-label-impl.h>
38 #include <dali-toolkit/internal/text/controller/text-controller.h>
39 #include <dali-toolkit/internal/text/font-description-run.h>
40 #include <dali-toolkit/internal/text/rendering/text-typesetter.h>
41 #include <dali-toolkit/internal/text/rendering/view-model.h>
42 #include <dali-toolkit/internal/text/text-view.h>
43 #include <dali-toolkit/public-api/text/text-enumerations.h>
44 #include <toolkit-text-utils.h>
45
46 using namespace Dali;
47 using namespace Toolkit;
48
49 namespace
50 {
51 const std::string DEFAULT_FONT_DIR("/resources/fonts");
52 const float       PIXEL_FORMAT_64_FACTOR = 64.f; ///< 64.f is used to convert from point size to 26.6 pixel format.
53 } // namespace
54
55 Text::SpannableString CreateSpannableStringForStrikethroughSpan()
56 {
57   Text::SpannableString spannableString = Text::SpannableString::New("Hello World");
58   DALI_TEST_CHECK(spannableString);
59
60   auto isAddedStrikethroughSpan = spannableString.AttachSpan(
61     Text::StrikethroughSpan::New(Color::GREEN, 5.0f),
62     Text::Range::New(5u, 7u));
63   DALI_TEST_CHECK(isAddedStrikethroughSpan);
64
65   return spannableString;
66 }
67
68 Text::SpannableString CreateSpannableStringForForegroundColorSpan()
69 {
70   Text::SpannableString spannableString = Text::SpannableString::New("Hello مرحبا");
71   DALI_TEST_CHECK(spannableString);
72
73   auto isAddedGreen = spannableString.AttachSpan(
74     Text::ForegroundColorSpan::New(Color::GREEN),
75     Text::Range::New(5u, 7u));
76   DALI_TEST_CHECK(isAddedGreen);
77
78   return spannableString;
79 }
80
81 Text::SpannableString CreateSpannableStringForFontSpan()
82 {
83   Text::SpannableString spannableString = Text::SpannableString::New("Hello World");
84   DALI_TEST_CHECK(spannableString);
85
86   auto isAddedFontSpan = spannableString.AttachSpan(
87     Text::FontSpan::New("TizenSans",
88                         45.0f,
89                         Dali::TextAbstraction::FontWeight::BOLD,
90                         Dali::TextAbstraction::FontWidth::SEMI_CONDENSED,
91                         Dali::TextAbstraction::FontSlant::OBLIQUE),
92     Text::Range::New(5u, 7u));
93   DALI_TEST_CHECK(isAddedFontSpan);
94
95   return spannableString;
96 }
97
98 Text::SpannableString CreateSpannableStringForUnderlineSpan()
99 {
100   Text::SpannableString spannableString = Text::SpannableString::New("Hello World");
101   DALI_TEST_CHECK(spannableString);
102
103   auto isAddedUnderlineSpan = spannableString.AttachSpan(
104     Text::UnderlineSpan::NewDashed(Color::GREEN, 5.0f, 2.0f, 3.0f),
105     Text::Range::New(5u, 7u));
106   DALI_TEST_CHECK(isAddedUnderlineSpan);
107
108   return spannableString;
109 }
110
111 Text::SpannableString CreateSpannableStringForCharacterSpacing()
112 {
113   Text::SpannableString spannableString = Text::SpannableString::New("Hello World");
114   DALI_TEST_CHECK(spannableString);
115
116   auto isCharacterSpacingSpan = spannableString.AttachSpan(
117     Text::CharacterSpacingSpan::New(5.2f),
118     Text::Range::New(5u, 7u));
119   DALI_TEST_CHECK(isCharacterSpacingSpan);
120
121   return spannableString;
122 }
123
124 Text::SpannableString CreateSpannableStringForBoldSpan()
125 {
126   Text::SpannableString spannableString = Text::SpannableString::New("Hello");
127   DALI_TEST_CHECK(spannableString);
128
129   auto boldspan   = Dali::Toolkit::Text::BoldSpan::New();
130   auto isBoldSpan = spannableString.AttachSpan(boldspan, Dali::Toolkit::Text::Range::New(0u, 3u));
131   DALI_TEST_CHECK(isBoldSpan);
132
133   return spannableString;
134 }
135
136 Text::SpannableString CreateSpannableStringForItalicSpan()
137 {
138   Text::SpannableString spannableString = Text::SpannableString::New("Hello");
139   DALI_TEST_CHECK(spannableString);
140
141   auto isAddedItalic = spannableString.AttachSpan(
142     Text::ItalicSpan::New(),
143     Text::Range::New(0u, 3u));
144   DALI_TEST_CHECK(isAddedItalic);
145
146   return spannableString;
147 }
148
149 Text::SpannableString CreateSpannableStringForBackgroundColorSpan()
150 {
151   Text::SpannableString spannableString = Text::SpannableString::New("Hello مرحبا");
152
153   DALI_TEST_CHECK(spannableString);
154
155   auto isAddedGreen = spannableString.AttachSpan(
156     Text::BackgroundColorSpan::New(Color::GREEN),
157     Text::Range::New(5u, 7u));
158   DALI_TEST_CHECK(isAddedGreen);
159
160   return spannableString;
161 }
162
163 void CheckColorIndices(const Text::ColorIndex* const colorIndicesBuffer,
164                        uint32_t                      numberOfIndices,
165                        std::vector<uint32_t>         indicesToCheck,
166                        std::vector<uint32_t>         expectedValues)
167 {
168   DALI_TEST_CHECK(colorIndicesBuffer);
169
170   for(uint32_t i = 0u; i < numberOfIndices; i++)
171   {
172     DALI_TEST_EQUALS(colorIndicesBuffer[indicesToCheck[i]], expectedValues[i], TEST_LOCATION);
173   }
174 }
175
176 int UtcDaliToolkitTextLabelSetSpannedText(void)
177 {
178   ToolkitTestApplication application;
179   tet_infoline(" UtcDaliToolkitTextLabelSetSpannedText");
180
181   TextLabel textLabel = TextLabel::New();
182   DALI_TEST_CHECK(textLabel);
183   application.GetScene().Add(textLabel);
184
185   Text::SpannableString spannableString = CreateSpannableStringForForegroundColorSpan();
186
187   Text::SetSpannedText(textLabel, spannableString);
188
189   application.SendNotification();
190   application.Render();
191
192   Toolkit::Internal::TextLabel& labelImpl          = GetImpl(textLabel);
193   const Text::ColorIndex* const colorIndicesBuffer = labelImpl.GetTextController()->GetTextModel()->GetColorIndices();
194
195   CheckColorIndices(colorIndicesBuffer, 4u, {0u, 5u, 7u, 10u}, {0u, 1u, 1u, 0u});
196
197   END_TEST;
198 }
199
200 int UtcDaliToolkitTextEditorSetSpannedText(void)
201 {
202   ToolkitTestApplication application;
203   tet_infoline(" UtcDaliToolkitTextEditorSetSpannedText");
204
205   TextEditor textEditor = TextEditor::New();
206   DALI_TEST_CHECK(textEditor);
207   application.GetScene().Add(textEditor);
208
209   Text::SpannableString spannableString = CreateSpannableStringForForegroundColorSpan();
210
211   Text::SetSpannedText(textEditor, spannableString);
212
213   application.SendNotification();
214   application.Render();
215
216   Toolkit::Internal::TextEditor& labelImpl          = GetImpl(textEditor);
217   const Text::ColorIndex* const  colorIndicesBuffer = labelImpl.GetTextController()->GetTextModel()->GetColorIndices();
218
219   CheckColorIndices(colorIndicesBuffer, 4u, {0u, 5u, 7u, 10u}, {0u, 1u, 1u, 0u});
220
221   END_TEST;
222 }
223
224 int UtcDaliToolkitTextFieldSetSpannedText(void)
225 {
226   ToolkitTestApplication application;
227   tet_infoline(" UtcDaliToolkitTextFieldSetSpannedText");
228
229   TextField textField = TextField::New();
230   DALI_TEST_CHECK(textField);
231   application.GetScene().Add(textField);
232
233   Text::SpannableString spannableString = CreateSpannableStringForForegroundColorSpan();
234
235   Text::SetSpannedText(textField, spannableString);
236
237   application.SendNotification();
238   application.Render();
239
240   Toolkit::Internal::TextField& labelImpl          = GetImpl(textField);
241   const Text::ColorIndex* const colorIndicesBuffer = labelImpl.GetTextController()->GetTextModel()->GetColorIndices();
242
243   CheckColorIndices(colorIndicesBuffer, 4u, {0u, 5u, 7u, 10u}, {0u, 1u, 1u, 0u});
244
245   END_TEST;
246 }
247
248 int UtcDaliToolkitTextLabelSetSpannedText_FontSpan(void)
249 {
250   ToolkitTestApplication application;
251   tet_infoline(" UtcDaliToolkitTextLabelSetSpannedText_FontSpan ");
252
253   // Load some fonts to get the same metrics on different platforms.
254   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
255   fontClient.SetDpi(96u, 96u);
256
257   char*             pathNamePtr = get_current_dir_name();
258   const std::string pathName(pathNamePtr);
259   free(pathNamePtr);
260
261   fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf");
262
263   TextLabel textLabel = TextLabel::New();
264   DALI_TEST_CHECK(textLabel);
265   application.GetScene().Add(textLabel);
266
267   Text::SpannableString spannableString = CreateSpannableStringForFontSpan();
268
269   Text::SetSpannedText(textLabel, spannableString);
270
271   application.SendNotification();
272   application.Render();
273
274   Toolkit::Internal::TextLabel&               labelImpl     = GetImpl(textLabel);
275   const Vector<Dali::Toolkit::Text::FontRun>& validFontRuns = labelImpl.GetTextController()->GetTextModel()->GetFontRuns();
276
277   DALI_TEST_EQUALS(validFontRuns.Count(), 3u, TEST_LOCATION);
278
279   DALI_TEST_EQUALS(validFontRuns[0].fontId, validFontRuns[2].fontId, TEST_LOCATION);
280   DALI_TEST_NOT_EQUALS(validFontRuns[0].fontId, validFontRuns[1].fontId, Math::MACHINE_EPSILON_100, TEST_LOCATION);
281
282   DALI_TEST_EQUALS(validFontRuns[1].characterRun.characterIndex, 5u, TEST_LOCATION);
283   DALI_TEST_EQUALS(validFontRuns[1].characterRun.GetEndCharacterIndex(), 7u, TEST_LOCATION);
284   DALI_TEST_EQUALS(validFontRuns[1].isItalicRequired, true, TEST_LOCATION);
285   DALI_TEST_EQUALS(validFontRuns[1].isBoldRequired, true, TEST_LOCATION);
286
287   TextAbstraction::FontDescription spanFontDescription;
288
289   float expectedPointSize = 45.0f * PIXEL_FORMAT_64_FACTOR;
290   float fontPointSize     = fontClient.GetPointSize(validFontRuns[1].fontId);
291   DALI_TEST_EQUALS(fontPointSize, expectedPointSize, TEST_LOCATION);
292
293   const Vector<Dali::Toolkit::Text::FontDescriptionRun>& validFontDescriptionRuns = labelImpl.GetTextController()->GetTextModel()->GetFontDescriptionRuns();
294   DALI_TEST_EQUALS(validFontDescriptionRuns.Count(), 1u, TEST_LOCATION);
295   std::string familyName = validFontDescriptionRuns[0].familyName;
296
297   DALI_TEST_EQUALS(familyName, "TizenSans", TEST_LOCATION);
298   DALI_TEST_EQUALS(validFontDescriptionRuns[0].size, expectedPointSize, TEST_LOCATION);
299   DALI_TEST_EQUALS(validFontDescriptionRuns[0].weight, Dali::TextAbstraction::FontWeight::BOLD, TEST_LOCATION);
300   DALI_TEST_EQUALS(validFontDescriptionRuns[0].width, Dali::TextAbstraction::FontWidth::SEMI_CONDENSED, TEST_LOCATION);
301   DALI_TEST_EQUALS(validFontDescriptionRuns[0].slant, Dali::TextAbstraction::FontSlant::OBLIQUE, TEST_LOCATION);
302
303   END_TEST;
304 }
305
306 int UtcDaliTextModelIsSpannedTextPlaced(void)
307
308 {
309   tet_infoline(" UtcDaliTextModelIsSpannedTextPlaced");
310
311   ToolkitTestApplication application;
312
313   // Create spanned-text and set it
314   Text::SpannableString spannedText = Text::SpannableString::New("Hello مرحبا");
315   DALI_TEST_CHECK(spannedText);
316
317   // Creates a text controller.
318   Dali::Toolkit::Text::ControllerPtr         controllerTextEditor = Dali::Toolkit::Text::Controller::New();
319   const Dali::Toolkit::Text::ModelInterface* modelEditor          = controllerTextEditor->GetTextModel();
320
321   // Tests the rendering controller has been created.
322   Dali::Toolkit::Text::TypesetterPtr typesetterEditor = Dali::Toolkit::Text::Typesetter::New(controllerTextEditor->GetTextModel());
323   DALI_TEST_CHECK(typesetterEditor);
324
325   // Tests the view model has been created.
326   Dali::Toolkit::Text::ViewModel* viewModelEditor = typesetterEditor->GetViewModel();
327   DALI_TEST_CHECK(viewModelEditor);
328
329   // Configures the text controller similarly to the text-editor.
330   Dali::Toolkit::Text::ConfigureTextEditor(controllerTextEditor);
331
332   DALI_TEST_EQUALS(false, modelEditor->IsSpannedTextPlaced(), TEST_LOCATION);
333   DALI_TEST_EQUALS(false, viewModelEditor->IsSpannedTextPlaced(), TEST_LOCATION);
334
335   controllerTextEditor->SetSpannedText(spannedText);
336
337   DALI_TEST_EQUALS(true, modelEditor->IsSpannedTextPlaced(), TEST_LOCATION);
338   DALI_TEST_EQUALS(true, viewModelEditor->IsSpannedTextPlaced(), TEST_LOCATION);
339
340   // Creates a text controller.
341   Dali::Toolkit::Text::ControllerPtr         controllerTextLabel = Dali::Toolkit::Text::Controller::New();
342   const Dali::Toolkit::Text::ModelInterface* modelLabel          = controllerTextLabel->GetTextModel();
343
344   // Tests the rendering controller has been created.
345   Dali::Toolkit::Text::TypesetterPtr typesetterLabel = Dali::Toolkit::Text::Typesetter::New(controllerTextLabel->GetTextModel());
346   DALI_TEST_CHECK(typesetterLabel);
347
348   // Tests the view model has been created.
349   Dali::Toolkit::Text::ViewModel* viewModelLabel = typesetterLabel->GetViewModel();
350   DALI_TEST_CHECK(viewModelLabel);
351
352   // Configures the text controller similarly to the text-label.
353   Dali::Toolkit::Text::ConfigureTextLabel(controllerTextLabel);
354
355   DALI_TEST_EQUALS(false, modelLabel->IsSpannedTextPlaced(), TEST_LOCATION);
356   DALI_TEST_EQUALS(false, viewModelLabel->IsSpannedTextPlaced(), TEST_LOCATION);
357
358   controllerTextLabel->SetSpannedText(spannedText);
359
360   DALI_TEST_EQUALS(true, modelLabel->IsSpannedTextPlaced(), TEST_LOCATION);
361   DALI_TEST_EQUALS(true, viewModelLabel->IsSpannedTextPlaced(), TEST_LOCATION);
362
363   // Creates a text controller.
364   Dali::Toolkit::Text::ControllerPtr         controllerTextField = Dali::Toolkit::Text::Controller::New();
365   const Dali::Toolkit::Text::ModelInterface* modelField          = controllerTextField->GetTextModel();
366
367   // Tests the rendering controller has been created.
368   Dali::Toolkit::Text::TypesetterPtr typesetterField = Dali::Toolkit::Text::Typesetter::New(controllerTextField->GetTextModel());
369   DALI_TEST_CHECK(typesetterField);
370
371   // Tests the view model has been created.
372   Dali::Toolkit::Text::ViewModel* viewModelField = typesetterField->GetViewModel();
373   DALI_TEST_CHECK(viewModelField);
374
375   // Configures the text controller similarly to the text-field.
376   Dali::Toolkit::Text::ConfigureTextField(controllerTextField);
377
378   DALI_TEST_EQUALS(false, modelField->IsSpannedTextPlaced(), TEST_LOCATION);
379   DALI_TEST_EQUALS(false, viewModelField->IsSpannedTextPlaced(), TEST_LOCATION);
380
381   controllerTextField->SetSpannedText(spannedText);
382
383   DALI_TEST_EQUALS(true, modelField->IsSpannedTextPlaced(), TEST_LOCATION);
384   DALI_TEST_EQUALS(true, viewModelField->IsSpannedTextPlaced(), TEST_LOCATION);
385
386   tet_result(TET_PASS);
387
388   END_TEST;
389 }
390
391 int UtcDaliToolkitTextLabelSetSpannedText_UnderlineSpan(void)
392 {
393   ToolkitTestApplication application;
394   tet_infoline(" UtcDaliToolkitTextLabelSetSpannedText_UnderlineSpan ");
395
396   Dali::Toolkit::Text::UnderlineStyleProperties expectedProperties = {
397     Text::Underline::DASHED,
398     Color::GREEN,
399     5u,
400     2u,
401     3u,
402     true,
403     true,
404     true,
405     true,
406     true};
407
408   TextLabel textLabel = TextLabel::New();
409   DALI_TEST_CHECK(textLabel);
410   application.GetScene().Add(textLabel);
411
412   Text::SpannableString spannableString = CreateSpannableStringForUnderlineSpan();
413
414   Text::SetSpannedText(textLabel, spannableString);
415
416   application.SendNotification();
417   application.Render();
418
419   Toolkit::Internal::TextLabel& labelImpl             = GetImpl(textLabel);
420   const Text::Length            numberOfUnderlineRuns = labelImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns();
421
422   DALI_TEST_EQUALS(numberOfUnderlineRuns, 1u, TEST_LOCATION);
423
424   Vector<Dali::Toolkit::Text::UnderlinedGlyphRun> underlineRuns;
425
426   underlineRuns.Resize(numberOfUnderlineRuns);
427
428   labelImpl.GetTextController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns);
429
430   DALI_TEST_EQUALS(underlineRuns[0].glyphRun.glyphIndex, 5u, TEST_LOCATION);
431   DALI_TEST_EQUALS(underlineRuns[0].glyphRun.numberOfGlyphs, 3u, TEST_LOCATION);
432   DALI_TEST_CHECK(underlineRuns[0].properties == expectedProperties);
433
434   END_TEST;
435 }
436
437 int UtcDaliToolkitTextLabelSetSpannedText_CharacterSpacingSpan(void)
438 {
439   ToolkitTestApplication application;
440   tet_infoline("UtcDaliToolkitTextLabelSetSpannedText_CharacterSpacingSpan");
441
442   TextLabel textLabel = TextLabel::New();
443   DALI_TEST_CHECK(textLabel);
444   application.GetScene().Add(textLabel);
445
446   Text::SpannableString spannableString = CreateSpannableStringForCharacterSpacing();
447   Text::SetSpannedText(textLabel, spannableString);
448
449   application.SendNotification();
450   application.Render();
451
452   Toolkit::Internal::TextLabel&                               labelImpl        = GetImpl(textLabel);
453   const Vector<Dali::Toolkit::Text::CharacterSpacingGlyphRun> characterSpacing = labelImpl.GetTextController()->GetTextModel()->GetCharacterSpacingGlyphRuns();
454   DALI_TEST_EQUALS(1, characterSpacing.Count(), TEST_LOCATION);
455   END_TEST;
456 }
457
458 int UtcDaliToolkitTextLabelSetSpannedText_BoldSpan(void)
459 {
460   ToolkitTestApplication application;
461
462   tet_infoline("UtcDaliToolkitTextLabelSetSpannedText_BoldSpan");
463
464   TextLabel textLabel = TextLabel::New();
465
466   DALI_TEST_CHECK(textLabel);
467
468   application.GetScene().Add(textLabel);
469
470   Text::SpannableString spannableString = CreateSpannableStringForBoldSpan();
471   Text::SetSpannedText(textLabel, spannableString);
472
473   application.SendNotification();
474   application.Render();
475
476   Toolkit::Internal::TextLabel& labelImpl = GetImpl(textLabel);
477
478   const Vector<Text::FontRun>& validFonts = labelImpl.GetTextController()->GetTextModel()->GetFontRuns();
479
480   DALI_TEST_EQUALS(validFonts.Count(), 2, TEST_LOCATION);
481   DALI_TEST_EQUALS(validFonts[0].characterRun.characterIndex, 0, TEST_LOCATION);
482   DALI_TEST_EQUALS(validFonts[0].characterRun.GetEndCharacterIndex(), 3, TEST_LOCATION);
483   DALI_TEST_EQUALS(validFonts[0].isBoldRequired, true, TEST_LOCATION);
484   END_TEST;
485 }
486
487 int UtcDaliToolkitTextLabelSetSpannedText_ItalicSpan(void)
488 {
489   ToolkitTestApplication application;
490   tet_infoline("UtcDaliToolkitTextLabelSetSpannedText_ItalicSpan");
491
492   TextLabel textLabel = TextLabel::New();
493   DALI_TEST_CHECK(textLabel);
494
495   application.GetScene().Add(textLabel);
496
497   Text::SpannableString spannableString = CreateSpannableStringForItalicSpan();
498
499   Text::SetSpannedText(textLabel, spannableString);
500   application.SendNotification();
501   application.Render();
502
503   Toolkit::Internal::TextLabel& labelImpl        = GetImpl(textLabel);
504   const Vector<Text::FontRun>&  validFontsItalic = labelImpl.GetTextController()->GetTextModel()->GetFontRuns();
505
506   DALI_TEST_EQUALS(validFontsItalic.Count(), 2, TEST_LOCATION);
507   DALI_TEST_EQUALS(validFontsItalic[0].characterRun.characterIndex, 0, TEST_LOCATION);
508   DALI_TEST_EQUALS(validFontsItalic[0].characterRun.GetEndCharacterIndex(), 3, TEST_LOCATION);
509   DALI_TEST_EQUALS(validFontsItalic[0].isItalicRequired, true, TEST_LOCATION);
510   END_TEST;
511 }
512
513 int UtcDaliToolkitTextLabelSetSpannedText_BackgroundColorSpan(void)
514 {
515   ToolkitTestApplication application;
516   tet_infoline("UtcDaliToolkitTextLabelSetSpannedText_BackgroundColorSpan");
517
518   TextLabel textLabel = TextLabel::New();
519   DALI_TEST_CHECK(textLabel);
520
521   application.GetScene().Add(textLabel);
522
523   Text::SpannableString spannableString = CreateSpannableStringForBackgroundColorSpan();
524   Text::SetSpannedText(textLabel, spannableString);
525
526   application.SendNotification();
527   application.Render();
528
529   Toolkit::Internal::TextLabel& labelImpl                    = GetImpl(textLabel);
530   const Text::ColorIndex* const backgroundColorIndicesBuffer = labelImpl.GetTextController()->GetTextModel()->GetBackgroundColorIndices();
531
532   CheckColorIndices(backgroundColorIndicesBuffer, 4u, {0u, 5u, 7u, 10u}, {0u, 1u, 1u, 0u});
533
534   END_TEST;
535 }
536
537 int UtcDaliToolkitTextLabelSetSpannedText_StrikethroughSpan(void)
538 {
539   ToolkitTestApplication application;
540
541   tet_infoline(" UtcDaliToolkitTextLabelSetSpannedText_StrikethroughSpan ");
542
543   Dali::Toolkit::Text::StrikethroughStyleProperties expectedProperties = {
544     Color::GREEN,
545     5u,
546     true,
547     true};
548
549   TextLabel textLabel = TextLabel::New();
550
551   DALI_TEST_CHECK(textLabel);
552
553   application.GetScene().Add(textLabel);
554
555   Text::SpannableString spannableString = CreateSpannableStringForStrikethroughSpan();
556   Text::SetSpannedText(textLabel, spannableString);
557
558   application.SendNotification();
559   application.Render();
560
561   Toolkit::Internal::TextLabel& labelImpl = GetImpl(textLabel);
562
563   const Text::Length numberOfStrikethroughRuns = labelImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns();
564
565   DALI_TEST_EQUALS(numberOfStrikethroughRuns, 1u, TEST_LOCATION);
566
567   Vector<Dali::Toolkit::Text::StrikethroughGlyphRun> strikethroughRuns;
568   strikethroughRuns.Resize(numberOfStrikethroughRuns);
569
570   labelImpl.GetTextController()->GetTextModel()->GetStrikethroughRuns(strikethroughRuns.Begin(), 0u, numberOfStrikethroughRuns);
571
572   DALI_TEST_EQUALS(strikethroughRuns[0].glyphRun.glyphIndex, 5u, TEST_LOCATION);
573   DALI_TEST_EQUALS(strikethroughRuns[0].glyphRun.numberOfGlyphs, 3u, TEST_LOCATION);
574   DALI_TEST_CHECK(strikethroughRuns[0].properties == expectedProperties);
575
576   END_TEST;
577 }