X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-internal%2Futc-Dali-TextLabel-internal.cpp;h=d9a3c047650650f31437f6d507f19b02f3128e80;hb=6f485d7d7c5b45e6b178d949d72e595d5a87121c;hp=2bd7df1f020c868ab0159b07e7e055c35d484e80;hpb=e6c8fad2c1ee24ce368976221941dfec12290b29;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git
diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextLabel-internal.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextLabel-internal.cpp
index 2bd7df1..d9a3c04 100644
--- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextLabel-internal.cpp
+++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextLabel-internal.cpp
@@ -561,6 +561,165 @@ int UtcDaliTextLabelMarkupNestedUnderlineTags(void)
END_TEST;
}
+int UtcDaliTextLabelMarkupNestedStrikethroughTags(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextLabelMarkupNestedStrikethroughTags ");
+
+ TextLabel textLabel = TextLabel::New();
+
+ application.GetScene().Add(textLabel);
+
+ std::string testText = "startABXYZCDEend";
+
+ textLabel.SetProperty(TextLabel::Property::TEXT, testText);
+ textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
+
+ application.SendNotification();
+ application.Render();
+
+ const uint32_t expectedNumberOfStrikethroughRuns = 2u;
+
+ Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
+ const Text::Length numberOfStrikethroughRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns();
+
+ DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughRuns, TEST_LOCATION);
+
+ Vector strikethroughRuns;
+ strikethroughRuns.Resize(numberOfStrikethroughRuns);
+ textLabelImpl.GetTextController()->GetTextModel()->GetStrikethroughRuns(strikethroughRuns.Begin(), 0u, numberOfStrikethroughRuns);
+
+ struct DataOfCase
+ {
+ std::string title;
+ GlyphIndex glyphIndex;
+ Length numberOfGlyphs;
+ StrikethroughStyleProperties properties;
+ };
+ DataOfCase data[] =
+ {
+ //Outter
+ {"ABXYZCDE",
+ 5u,
+ 8u,
+ {
+ Color::GREEN,
+ 5.0f,
+ true,
+ true,
+ }},
+
+ //Inner
+ {"XYZ",
+ 7u,
+ 3u,
+ {
+ Color::BLUE,
+ 5.0f,
+ true,
+ true,
+ }},
+
+ };
+
+ for(uint32_t i = 0; i < expectedNumberOfStrikethroughRuns; i++)
+ {
+ tet_infoline(data[i].title.c_str());
+ DALI_TEST_EQUALS(strikethroughRuns[i].glyphRun.glyphIndex, data[i].glyphIndex, TEST_LOCATION);
+ DALI_TEST_EQUALS(strikethroughRuns[i].glyphRun.numberOfGlyphs, data[i].numberOfGlyphs, TEST_LOCATION);
+ DALI_TEST_CHECK(data[i].properties == strikethroughRuns[i].properties);
+ }
+
+ END_TEST;
+}
+
+int UtcDaliTextLabelMarkupStrikethroughAttributes(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextLabelMarkupStrikethroughAttributes ");
+
+ TextLabel textLabel = TextLabel::New();
+
+ application.GetScene().Add(textLabel);
+
+ std::string testText =
+ "startABC1then"
+ "ABC2then"
+ "ABC3then"
+ "ABC4end";
+
+ textLabel.SetProperty(TextLabel::Property::TEXT, testText);
+ textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
+
+ application.SendNotification();
+ application.Render();
+
+ const uint32_t expectedNumberOfStrikethroughRuns = 4u;
+
+ Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
+ const Text::Length numberOfStrikethroughRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns();
+
+ DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughRuns, TEST_LOCATION);
+
+ Vector strikethroughRuns;
+ strikethroughRuns.Resize(numberOfStrikethroughRuns);
+ textLabelImpl.GetTextController()->GetTextModel()->GetStrikethroughRuns(strikethroughRuns.Begin(), 0u, numberOfStrikethroughRuns);
+
+ struct DataOfCase
+ {
+ std::string title;
+ GlyphIndex glyphIndex;
+ Length numberOfGlyphs;
+ StrikethroughStyleProperties properties;
+ };
+ DataOfCase data[] =
+ {
+
+ {"ABC1",
+ 5u,
+ 4u,
+ {Color::BLACK,
+ 0.0f,
+ false,
+ false}},
+
+ {"ABC2",
+ 13u,
+ 4u,
+ {Color::GREEN,
+ 0.0f,
+ true,
+ false}},
+
+ {"ABC3",
+ 21u,
+ 4u,
+ {Color::BLACK,
+ 5.0f,
+ false,
+ true}},
+
+ {"ABC4",
+ 29u,
+ 4u,
+ {Color::BLUE,
+ 4.0f,
+ true,
+ true}},
+
+ };
+
+ for(uint32_t i = 0; i < expectedNumberOfStrikethroughRuns; i++)
+ {
+ tet_infoline(data[i].title.c_str());
+ DALI_TEST_EQUALS(strikethroughRuns[i].glyphRun.glyphIndex, data[i].glyphIndex, TEST_LOCATION);
+ DALI_TEST_EQUALS(strikethroughRuns[i].glyphRun.numberOfGlyphs, data[i].numberOfGlyphs, TEST_LOCATION);
+ DALI_TEST_CHECK(data[i].properties == strikethroughRuns[i].properties);
+ }
+
+ END_TEST;
+}
+
int UtcDaliTextLabelMarkupSpanStrikethrough(void)
{
ToolkitTestApplication application;
@@ -573,7 +732,8 @@ int UtcDaliTextLabelMarkupSpanStrikethrough(void)
std::string testText =
"startABC1then"
"ABC2then"
- "ABC3end";
+ "ABC3then"
+ "ABC4end";
textLabel.SetProperty(TextLabel::Property::TEXT, testText);
textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
@@ -581,7 +741,7 @@ int UtcDaliTextLabelMarkupSpanStrikethrough(void)
application.SendNotification();
application.Render();
- const uint32_t expectedNumberOfStrikethroughRuns = 2u;
+ const uint32_t expectedNumberOfStrikethroughRuns = 3u;
Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
const Text::Length numberOfStrikethroughRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns();
@@ -606,17 +766,25 @@ int UtcDaliTextLabelMarkupSpanStrikethrough(void)
13u,
4u,
{Color::BLUE,
- 0u,
+ 0.0f,
true,
false}},
- {"ABC3",
+ {"ABC3then",
21u,
4u,
+ {Color::BLACK,
+ 2.0f,
+ false,
+ true}},
+
+ {"ABC4",
+ 29u,
+ 4u,
{Color::GREEN,
- 0u,
+ 5.0f,
true,
- false}},
+ true}},
};
@@ -1053,3 +1221,120 @@ int UtcDaliTextLabelMarkupParagraphTagAlignAttribute(void)
END_TEST;
}
+
+int UtcDaliTextLabelMarkupCharacterSpacingTag(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextLabelMarkupCharacterSpacingTag ");
+
+ const Length EXPECTED_NUMBER_OF_GLYPHS = 21u;
+
+ const float expandedCharSpacing = 10.0f;
+ const float condensedCharSpacing = -5.0f;
+
+ TextLabel textLabel = TextLabel::New();
+
+ textLabel.SetProperty(TextLabel::Property::TEXT, "ABC EF\nABC EF\nABC EF\n");
+ textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
+ textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
+
+ application.GetScene().Add(textLabel);
+
+ application.SendNotification();
+ application.Render();
+
+ Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
+ Text::ViewInterface& view = textLabelImpl.GetTextController()->GetView();
+
+ Length numberOfGlyphs = view.GetNumberOfGlyphs();
+
+ DALI_TEST_EQUALS(numberOfGlyphs, EXPECTED_NUMBER_OF_GLYPHS, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
+
+ Vector glyphs;
+ glyphs.Resize(numberOfGlyphs);
+
+ Vector positions;
+ positions.Resize(numberOfGlyphs);
+
+ float alignmentOffset = 0u;
+ numberOfGlyphs = view.GetGlyphs(glyphs.Begin(),
+ positions.Begin(),
+ alignmentOffset,
+ 0u,
+ numberOfGlyphs);
+
+ const Length numberOfGlyphsOneLine = 7u;
+ for(Length i = 0; i < numberOfGlyphsOneLine - 1u; i++)
+ {
+ float diffLineNoCharSpacing = positions[i + 1].x - positions[i].x;
+
+ float diffLineCondensedCharSpacing = positions[numberOfGlyphsOneLine + i + 1].x - positions[numberOfGlyphsOneLine + i].x;
+ DALI_TEST_EQUALS(diffLineCondensedCharSpacing, diffLineNoCharSpacing + condensedCharSpacing, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
+
+ float diffLineExpandedCharSpacing = positions[2u * numberOfGlyphsOneLine + i + 1].x - positions[2u * numberOfGlyphsOneLine + i].x;
+ DALI_TEST_EQUALS(diffLineExpandedCharSpacing, diffLineNoCharSpacing + expandedCharSpacing, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
+ }
+
+ END_TEST;
+}
+
+int UtcDaliTextLabelMarkupSpanCharacterSpacing(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextLabelMarkupSpanCharacterSpacing ");
+
+ const Length EXPECTED_NUMBER_OF_GLYPHS = 21u;
+
+ const float expandedCharSpacing = 10.0f;
+ const float condensedCharSpacing = -5.0f;
+
+ std::string testText =
+ "ABC EF\n"
+ "ABC EF\n"
+ "ABC EF\n";
+
+ TextLabel textLabel = TextLabel::New();
+
+ textLabel.SetProperty(TextLabel::Property::TEXT, testText);
+ textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true);
+ textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
+
+ application.GetScene().Add(textLabel);
+
+ application.SendNotification();
+ application.Render();
+
+ Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel);
+ Text::ViewInterface& view = textLabelImpl.GetTextController()->GetView();
+
+ Length numberOfGlyphs = view.GetNumberOfGlyphs();
+
+ DALI_TEST_EQUALS(numberOfGlyphs, EXPECTED_NUMBER_OF_GLYPHS, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
+
+ Vector glyphs;
+ glyphs.Resize(numberOfGlyphs);
+
+ Vector positions;
+ positions.Resize(numberOfGlyphs);
+
+ float alignmentOffset = 0u;
+ numberOfGlyphs = view.GetGlyphs(glyphs.Begin(),
+ positions.Begin(),
+ alignmentOffset,
+ 0u,
+ numberOfGlyphs);
+
+ const Length numberOfGlyphsOneLine = 7u;
+ for(Length i = 0; i < numberOfGlyphsOneLine - 1u; i++)
+ {
+ float diffLineNoCharSpacing = positions[i + 1].x - positions[i].x;
+
+ float diffLineCondensedCharSpacing = positions[numberOfGlyphsOneLine + i + 1].x - positions[numberOfGlyphsOneLine + i].x;
+ DALI_TEST_EQUALS(diffLineCondensedCharSpacing, diffLineNoCharSpacing + condensedCharSpacing, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
+
+ float diffLineExpandedCharSpacing = positions[2u * numberOfGlyphsOneLine + i + 1].x - positions[2u * numberOfGlyphsOneLine + i].x;
+ DALI_TEST_EQUALS(diffLineExpandedCharSpacing, diffLineNoCharSpacing + expandedCharSpacing, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
+ }
+
+ END_TEST;
+}
\ No newline at end of file