Commit 245ddc91 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[FragmentItem] Fix NGInlineLayoutAlgorithmTest.BreakToken

The DCHECK was added to ensure |AddLine| is executed after
|SetCurrentLine|, which is not true for this unit test.

Bug: 982194
Change-Id: Idfdb0f5bd61f973937ffbc19c0da2e7d8d268047
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2262028
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781781}
parent e1059908
......@@ -42,11 +42,15 @@ void NGFragmentItemsBuilder::SetCurrentLine(
#if DCHECK_IS_ON()
current_line_fragment_ = &line;
#endif
DCHECK(!current_line_);
DCHECK(current_line);
DCHECK(!current_line_); // Check |AddLine| runs after |SetCurrentLine|.
current_line_ = current_line;
}
void NGFragmentItemsBuilder::ClearCurrentLineForTesting() {
current_line_ = nullptr;
}
void NGFragmentItemsBuilder::AddLine(const NGPhysicalLineBoxFragment& line,
const LogicalOffset& offset) {
DCHECK(!is_converted_to_physical_);
......
......@@ -62,6 +62,7 @@ class CORE_EXPORT NGFragmentItemsBuilder {
NGLogicalLineItems* current_line);
void AddLine(const NGPhysicalLineBoxFragment& line,
const LogicalOffset& offset);
void ClearCurrentLineForTesting();
// Add a list marker to the current line.
void AddListMarker(const NGPhysicalBoxFragment& marker_fragment,
......
......@@ -67,12 +67,14 @@ TEST_F(NGInlineLayoutAlgorithmTest, BreakToken) {
EXPECT_FALSE(line1.BreakToken()->IsFinished());
// Perform 2nd layout with the break token from the 1st line.
items_builder.ClearCurrentLineForTesting();
scoped_refptr<const NGLayoutResult> layout_result2 =
inline_node.Layout(constraint_space, line1.BreakToken(), &context);
const auto& line2 = layout_result2->PhysicalFragment();
EXPECT_FALSE(line2.BreakToken()->IsFinished());
// Perform 3rd layout with the break token from the 2nd line.
items_builder.ClearCurrentLineForTesting();
scoped_refptr<const NGLayoutResult> layout_result3 =
inline_node.Layout(constraint_space, line2.BreakToken(), &context);
const auto& line3 = layout_result3->PhysicalFragment();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment