Specify the Noto Naskh Arabic font to get consistent results in tests using Arabic characters (flutter/engine#21974)
See https://github.com/flutter/flutter/issues/68493
This commit is contained in:
@@ -39,6 +39,4 @@
|
||||
FRIEND_TEST_LINUX_ONLY_EXPANDED(SUITE, DISABLE_TEST_LINUX(TEST_NAME))
|
||||
#endif // defined(__linux__)
|
||||
|
||||
#define LINUX_ONLY_DISABLED(TEST_NAME) DISABLED_##TEST_NAME
|
||||
|
||||
#endif // LINUX_UTILS_H
|
||||
|
||||
@@ -3973,23 +3973,21 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(GetRectsForRangeCenterParagraph)) {
|
||||
ASSERT_TRUE(Snapshot());
|
||||
}
|
||||
|
||||
// 10/19/20 Temporarily disabled tests while being they are being fixed.
|
||||
// https://github.com/flutter/flutter/issues/68493
|
||||
TEST_F(ParagraphTest,
|
||||
LINUX_ONLY_DISABLED(GetRectsForRangeParagraphNewlineLeftAlign)) {
|
||||
TEST_F(ParagraphTest, LINUX_ONLY(GetRectsForRangeParagraphNewlineLeftAlign)) {
|
||||
const char* text = "01234\n\nعab\naعلی\n";
|
||||
auto icu_text = icu::UnicodeString::fromUTF8(text);
|
||||
std::u16string u16_text(icu_text.getBuffer(),
|
||||
icu_text.getBuffer() + icu_text.length());
|
||||
|
||||
txt::ParagraphStyle paragraph_style;
|
||||
paragraph_style.font_family = "Roboto";
|
||||
paragraph_style.max_lines = 10;
|
||||
paragraph_style.text_direction = TextDirection::ltr;
|
||||
paragraph_style.text_align = TextAlign::left;
|
||||
txt::ParagraphBuilderTxt builder(paragraph_style, GetTestFontCollection());
|
||||
|
||||
txt::TextStyle text_style;
|
||||
text_style.font_families = std::vector<std::string>(1, "Roboto");
|
||||
text_style.font_families = {"Roboto", "Noto Naskh Arabic"};
|
||||
text_style.font_size = 50;
|
||||
text_style.letter_spacing = 0;
|
||||
text_style.font_weight = FontWeight::w500;
|
||||
@@ -4056,9 +4054,9 @@ TEST_F(ParagraphTest,
|
||||
GetCanvas()->drawRect(boxes[i].rect, paint);
|
||||
}
|
||||
EXPECT_EQ(boxes.size(), 1ull);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 77);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 77);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 134);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 85);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 85);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 160);
|
||||
|
||||
boxes =
|
||||
paragraph->GetRectsForRange(15, 16, rect_height_style, rect_width_style);
|
||||
@@ -4068,26 +4066,26 @@ TEST_F(ParagraphTest,
|
||||
EXPECT_EQ(boxes.size(), 1ull);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 27);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 27);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 193);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 245);
|
||||
|
||||
ASSERT_TRUE(Snapshot());
|
||||
}
|
||||
|
||||
TEST_F(ParagraphTest,
|
||||
LINUX_ONLY_DISABLED(GetRectsForRangeParagraphNewlineRightAlign)) {
|
||||
TEST_F(ParagraphTest, LINUX_ONLY(GetRectsForRangeParagraphNewlineRightAlign)) {
|
||||
const char* text = "01234\n\nعab\naعلی\n";
|
||||
auto icu_text = icu::UnicodeString::fromUTF8(text);
|
||||
std::u16string u16_text(icu_text.getBuffer(),
|
||||
icu_text.getBuffer() + icu_text.length());
|
||||
|
||||
txt::ParagraphStyle paragraph_style;
|
||||
paragraph_style.font_family = "Roboto";
|
||||
paragraph_style.max_lines = 10;
|
||||
paragraph_style.text_direction = TextDirection::ltr;
|
||||
paragraph_style.text_align = TextAlign::right;
|
||||
txt::ParagraphBuilderTxt builder(paragraph_style, GetTestFontCollection());
|
||||
|
||||
txt::TextStyle text_style;
|
||||
text_style.font_families = std::vector<std::string>(1, "Roboto");
|
||||
text_style.font_families = {"Roboto", "Noto Naskh Arabic"};
|
||||
text_style.font_size = 50;
|
||||
text_style.letter_spacing = 0;
|
||||
text_style.font_weight = FontWeight::w500;
|
||||
@@ -4156,7 +4154,7 @@ TEST_F(ParagraphTest,
|
||||
EXPECT_EQ(boxes.size(), 1ull);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 550);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 550);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 134);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 160);
|
||||
|
||||
boxes =
|
||||
paragraph->GetRectsForRange(15, 16, rect_height_style, rect_width_style);
|
||||
@@ -4164,28 +4162,29 @@ TEST_F(ParagraphTest,
|
||||
GetCanvas()->drawRect(boxes[i].rect, paint);
|
||||
}
|
||||
EXPECT_EQ(boxes.size(), 1ull);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 483);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 483);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 193);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 478);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 478);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 245);
|
||||
|
||||
ASSERT_TRUE(Snapshot());
|
||||
}
|
||||
|
||||
TEST_F(ParagraphTest,
|
||||
LINUX_ONLY_DISABLED(GetRectsForRangeCenterParagraphNewlineCentered)) {
|
||||
LINUX_ONLY(GetRectsForRangeCenterParagraphNewlineCentered)) {
|
||||
const char* text = "01234\n\nعab\naعلی\n";
|
||||
auto icu_text = icu::UnicodeString::fromUTF8(text);
|
||||
std::u16string u16_text(icu_text.getBuffer(),
|
||||
icu_text.getBuffer() + icu_text.length());
|
||||
|
||||
txt::ParagraphStyle paragraph_style;
|
||||
paragraph_style.font_family = "Roboto";
|
||||
paragraph_style.max_lines = 10;
|
||||
paragraph_style.text_direction = TextDirection::ltr;
|
||||
paragraph_style.text_align = TextAlign::center;
|
||||
txt::ParagraphBuilderTxt builder(paragraph_style, GetTestFontCollection());
|
||||
|
||||
txt::TextStyle text_style;
|
||||
text_style.font_families = std::vector<std::string>(1, "Roboto");
|
||||
text_style.font_families = {"Roboto", "Noto Naskh Arabic"};
|
||||
text_style.font_size = 50;
|
||||
text_style.letter_spacing = 0;
|
||||
text_style.font_weight = FontWeight::w500;
|
||||
@@ -4252,9 +4251,9 @@ TEST_F(ParagraphTest,
|
||||
GetCanvas()->drawRect(boxes[i].rect, paint);
|
||||
}
|
||||
EXPECT_EQ(boxes.size(), 1ull);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 313);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 313);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 134);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 317);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 317);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 160);
|
||||
|
||||
boxes =
|
||||
paragraph->GetRectsForRange(15, 16, rect_height_style, rect_width_style);
|
||||
@@ -4262,28 +4261,29 @@ TEST_F(ParagraphTest,
|
||||
GetCanvas()->drawRect(boxes[i].rect, paint);
|
||||
}
|
||||
EXPECT_EQ(boxes.size(), 1ull);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 255);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 255);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 193);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 252);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 252);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 245);
|
||||
|
||||
ASSERT_TRUE(Snapshot());
|
||||
}
|
||||
|
||||
TEST_F(ParagraphTest,
|
||||
LINUX_ONLY_DISABLED(GetRectsForRangeParagraphNewlineRTLLeftAlign)) {
|
||||
LINUX_ONLY(GetRectsForRangeParagraphNewlineRTLLeftAlign)) {
|
||||
const char* text = "01234\n\nعab\naعلی\n";
|
||||
auto icu_text = icu::UnicodeString::fromUTF8(text);
|
||||
std::u16string u16_text(icu_text.getBuffer(),
|
||||
icu_text.getBuffer() + icu_text.length());
|
||||
|
||||
txt::ParagraphStyle paragraph_style;
|
||||
paragraph_style.font_family = "Roboto";
|
||||
paragraph_style.max_lines = 10;
|
||||
paragraph_style.text_direction = TextDirection::rtl;
|
||||
paragraph_style.text_align = TextAlign::left;
|
||||
txt::ParagraphBuilderTxt builder(paragraph_style, GetTestFontCollection());
|
||||
|
||||
txt::TextStyle text_style;
|
||||
text_style.font_families = std::vector<std::string>(1, "Roboto");
|
||||
text_style.font_families = {"Roboto", "Noto Naskh Arabic"};
|
||||
text_style.font_size = 50;
|
||||
text_style.letter_spacing = 0;
|
||||
text_style.font_weight = FontWeight::w500;
|
||||
@@ -4352,7 +4352,7 @@ TEST_F(ParagraphTest,
|
||||
EXPECT_EQ(boxes.size(), 1ull);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 55);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 55);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 134);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 160);
|
||||
|
||||
boxes =
|
||||
paragraph->GetRectsForRange(15, 16, rect_height_style, rect_width_style);
|
||||
@@ -4362,26 +4362,27 @@ TEST_F(ParagraphTest,
|
||||
EXPECT_EQ(boxes.size(), 1ull);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 0);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 0);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 193);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 245);
|
||||
|
||||
ASSERT_TRUE(Snapshot());
|
||||
}
|
||||
|
||||
TEST_F(ParagraphTest,
|
||||
LINUX_ONLY_DISABLED(GetRectsForRangeParagraphNewlineRTLRightAlign)) {
|
||||
LINUX_ONLY(GetRectsForRangeParagraphNewlineRTLRightAlign)) {
|
||||
const char* text = "01234\n\nعab\naعلی\n";
|
||||
auto icu_text = icu::UnicodeString::fromUTF8(text);
|
||||
std::u16string u16_text(icu_text.getBuffer(),
|
||||
icu_text.getBuffer() + icu_text.length());
|
||||
|
||||
txt::ParagraphStyle paragraph_style;
|
||||
paragraph_style.font_family = "Roboto";
|
||||
paragraph_style.max_lines = 10;
|
||||
paragraph_style.text_direction = TextDirection::rtl;
|
||||
paragraph_style.text_align = TextAlign::right;
|
||||
txt::ParagraphBuilderTxt builder(paragraph_style, GetTestFontCollection());
|
||||
|
||||
txt::TextStyle text_style;
|
||||
text_style.font_families = std::vector<std::string>(1, "Roboto");
|
||||
text_style.font_families = {"Roboto", "Noto Naskh Arabic"};
|
||||
text_style.font_size = 50;
|
||||
text_style.letter_spacing = 0;
|
||||
text_style.font_weight = FontWeight::w500;
|
||||
@@ -4448,9 +4449,9 @@ TEST_F(ParagraphTest,
|
||||
GetCanvas()->drawRect(boxes[i].rect, paint);
|
||||
}
|
||||
EXPECT_EQ(boxes.size(), 1ull);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 527);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 527);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 134);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 519);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 519);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 160);
|
||||
|
||||
boxes =
|
||||
paragraph->GetRectsForRange(15, 16, rect_height_style, rect_width_style);
|
||||
@@ -4458,28 +4459,29 @@ TEST_F(ParagraphTest,
|
||||
GetCanvas()->drawRect(boxes[i].rect, paint);
|
||||
}
|
||||
EXPECT_EQ(boxes.size(), 1ull);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 456);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 456);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 193);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 451);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 451);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 245);
|
||||
|
||||
ASSERT_TRUE(Snapshot());
|
||||
}
|
||||
|
||||
TEST_F(ParagraphTest,
|
||||
LINUX_ONLY_DISABLED(GetRectsForRangeCenterParagraphNewlineRTLCentered)) {
|
||||
LINUX_ONLY(GetRectsForRangeCenterParagraphNewlineRTLCentered)) {
|
||||
const char* text = "01234\n\nعab\naعلی\n";
|
||||
auto icu_text = icu::UnicodeString::fromUTF8(text);
|
||||
std::u16string u16_text(icu_text.getBuffer(),
|
||||
icu_text.getBuffer() + icu_text.length());
|
||||
|
||||
txt::ParagraphStyle paragraph_style;
|
||||
paragraph_style.font_family = "Roboto";
|
||||
paragraph_style.max_lines = 10;
|
||||
paragraph_style.text_direction = TextDirection::rtl;
|
||||
paragraph_style.text_align = TextAlign::center;
|
||||
txt::ParagraphBuilderTxt builder(paragraph_style, GetTestFontCollection());
|
||||
|
||||
txt::TextStyle text_style;
|
||||
text_style.font_families = std::vector<std::string>(1, "Roboto");
|
||||
text_style.font_families = {"Roboto", "Noto Naskh Arabic"};
|
||||
text_style.font_size = 50;
|
||||
text_style.letter_spacing = 0;
|
||||
text_style.font_weight = FontWeight::w500;
|
||||
@@ -4546,9 +4548,9 @@ TEST_F(ParagraphTest,
|
||||
GetCanvas()->drawRect(boxes[i].rect, paint);
|
||||
}
|
||||
EXPECT_EQ(boxes.size(), 1ull);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 291);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 291);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 134);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 287);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 287);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 160);
|
||||
|
||||
boxes =
|
||||
paragraph->GetRectsForRange(15, 16, rect_height_style, rect_width_style);
|
||||
@@ -4556,9 +4558,9 @@ TEST_F(ParagraphTest,
|
||||
GetCanvas()->drawRect(boxes[i].rect, paint);
|
||||
}
|
||||
EXPECT_EQ(boxes.size(), 1ull);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 228);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 228);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 193);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 225);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 225);
|
||||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 245);
|
||||
|
||||
ASSERT_TRUE(Snapshot());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user