mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Fix Libtxt unit test errors found by ASAN (flutter/engine#28146)
This commit is contained in:
parent
d5eed6ce6e
commit
d85d394682
@ -1992,7 +1992,8 @@ Paragraph::Range<size_t> ParagraphTxt::GetWordBoundary(size_t offset) {
|
||||
return Range<size_t>(0, 0);
|
||||
}
|
||||
|
||||
word_breaker_->setText(icu::UnicodeString(false, text_.data(), text_.size()));
|
||||
icu::UnicodeString icu_text(false, text_.data(), text_.size());
|
||||
word_breaker_->setText(icu_text);
|
||||
|
||||
int32_t prev_boundary = word_breaker_->preceding(offset + 1);
|
||||
int32_t next_boundary = word_breaker_->next();
|
||||
|
||||
@ -54,6 +54,8 @@ bool TextStyle::equals(const TextStyle& other) const {
|
||||
return false;
|
||||
if (foreground != other.foreground)
|
||||
return false;
|
||||
if (font_families.size() != other.font_families.size())
|
||||
return false;
|
||||
if (text_shadows.size() != other.text_shadows.size())
|
||||
return false;
|
||||
for (size_t font_index = 0; font_index < font_families.size(); ++font_index) {
|
||||
|
||||
@ -2489,11 +2489,10 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(RightAlignParagraph)) {
|
||||
ASSERT_TRUE(paragraph->records_[0].style().equals(text_style));
|
||||
ASSERT_DOUBLE_EQ(paragraph->records_[0].offset().y(), expected_y);
|
||||
expected_y += 30;
|
||||
ASSERT_NEAR(
|
||||
paragraph->records_[0].offset().x(),
|
||||
paragraph->width_ -
|
||||
paragraph->breaker_.getWidths()[paragraph->records_[0].line()],
|
||||
2.0);
|
||||
ASSERT_NEAR(paragraph->records_[0].offset().x(),
|
||||
paragraph->width_ -
|
||||
paragraph->line_widths_[paragraph->records_[0].line()],
|
||||
2.0);
|
||||
|
||||
// width_ takes the full available space, while longest_line_ wraps the glyphs
|
||||
// as tightly as possible. Even though this text is more than one line long,
|
||||
@ -2506,37 +2505,33 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(RightAlignParagraph)) {
|
||||
ASSERT_TRUE(paragraph->records_[2].style().equals(text_style));
|
||||
ASSERT_DOUBLE_EQ(paragraph->records_[2].offset().y(), expected_y);
|
||||
expected_y += 30;
|
||||
ASSERT_NEAR(
|
||||
paragraph->records_[2].offset().x(),
|
||||
paragraph->width_ -
|
||||
paragraph->breaker_.getWidths()[paragraph->records_[2].line()],
|
||||
2.0);
|
||||
ASSERT_NEAR(paragraph->records_[2].offset().x(),
|
||||
paragraph->width_ -
|
||||
paragraph->line_widths_[paragraph->records_[2].line()],
|
||||
2.0);
|
||||
|
||||
ASSERT_TRUE(paragraph->records_[4].style().equals(text_style));
|
||||
ASSERT_DOUBLE_EQ(paragraph->records_[4].offset().y(), expected_y);
|
||||
expected_y += 30;
|
||||
ASSERT_NEAR(
|
||||
paragraph->records_[4].offset().x(),
|
||||
paragraph->width_ -
|
||||
paragraph->breaker_.getWidths()[paragraph->records_[4].line()],
|
||||
2.0);
|
||||
ASSERT_NEAR(paragraph->records_[4].offset().x(),
|
||||
paragraph->width_ -
|
||||
paragraph->line_widths_[paragraph->records_[4].line()],
|
||||
2.0);
|
||||
|
||||
ASSERT_TRUE(paragraph->records_[6].style().equals(text_style));
|
||||
ASSERT_DOUBLE_EQ(paragraph->records_[6].offset().y(), expected_y);
|
||||
expected_y += 30 * 10;
|
||||
ASSERT_NEAR(
|
||||
paragraph->records_[6].offset().x(),
|
||||
paragraph->width_ -
|
||||
paragraph->breaker_.getWidths()[paragraph->records_[6].line()],
|
||||
2.0);
|
||||
ASSERT_NEAR(paragraph->records_[6].offset().x(),
|
||||
paragraph->width_ -
|
||||
paragraph->line_widths_[paragraph->records_[6].line()],
|
||||
2.0);
|
||||
|
||||
ASSERT_TRUE(paragraph->records_[26].style().equals(text_style));
|
||||
ASSERT_DOUBLE_EQ(paragraph->records_[26].offset().y(), expected_y);
|
||||
ASSERT_NEAR(
|
||||
paragraph->records_[26].offset().x(),
|
||||
paragraph->width_ -
|
||||
paragraph->breaker_.getWidths()[paragraph->records_[26].line()],
|
||||
2.0);
|
||||
ASSERT_NEAR(paragraph->records_[26].offset().x(),
|
||||
paragraph->width_ -
|
||||
paragraph->line_widths_[paragraph->records_[26].line()],
|
||||
2.0);
|
||||
|
||||
ASSERT_EQ(paragraph_style.text_align,
|
||||
paragraph->GetParagraphStyle().text_align);
|
||||
@ -2609,7 +2604,7 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(CenterAlignParagraph)) {
|
||||
expected_y += 30;
|
||||
ASSERT_NEAR(paragraph->records_[0].offset().x(),
|
||||
(paragraph->width_ -
|
||||
paragraph->breaker_.getWidths()[paragraph->records_[0].line()]) /
|
||||
paragraph->line_widths_[paragraph->records_[0].line()]) /
|
||||
2,
|
||||
2.0);
|
||||
|
||||
@ -2618,7 +2613,7 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(CenterAlignParagraph)) {
|
||||
expected_y += 30;
|
||||
ASSERT_NEAR(paragraph->records_[2].offset().x(),
|
||||
(paragraph->width_ -
|
||||
paragraph->breaker_.getWidths()[paragraph->records_[2].line()]) /
|
||||
paragraph->line_widths_[paragraph->records_[2].line()]) /
|
||||
2,
|
||||
2.0);
|
||||
|
||||
@ -2627,7 +2622,7 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(CenterAlignParagraph)) {
|
||||
expected_y += 30;
|
||||
ASSERT_NEAR(paragraph->records_[4].offset().x(),
|
||||
(paragraph->width_ -
|
||||
paragraph->breaker_.getWidths()[paragraph->records_[4].line()]) /
|
||||
paragraph->line_widths_[paragraph->records_[4].line()]) /
|
||||
2,
|
||||
2.0);
|
||||
|
||||
@ -2636,18 +2631,17 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(CenterAlignParagraph)) {
|
||||
expected_y += 30 * 10;
|
||||
ASSERT_NEAR(paragraph->records_[6].offset().x(),
|
||||
(paragraph->width_ -
|
||||
paragraph->breaker_.getWidths()[paragraph->records_[6].line()]) /
|
||||
paragraph->line_widths_[paragraph->records_[6].line()]) /
|
||||
2,
|
||||
2.0);
|
||||
|
||||
ASSERT_TRUE(paragraph->records_[26].style().equals(text_style));
|
||||
ASSERT_DOUBLE_EQ(paragraph->records_[26].offset().y(), expected_y);
|
||||
ASSERT_NEAR(
|
||||
paragraph->records_[26].offset().x(),
|
||||
(paragraph->width_ -
|
||||
paragraph->breaker_.getWidths()[paragraph->records_[26].line()]) /
|
||||
2,
|
||||
2.0);
|
||||
ASSERT_NEAR(paragraph->records_[26].offset().x(),
|
||||
(paragraph->width_ -
|
||||
paragraph->line_widths_[paragraph->records_[26].line()]) /
|
||||
2,
|
||||
2.0);
|
||||
|
||||
ASSERT_EQ(paragraph_style.text_align,
|
||||
paragraph->GetParagraphStyle().text_align);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user