Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc |
| diff --git a/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc b/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc |
| index 37499446187cc4792c43141e13e1d0dc6b406d24..6770fe4974df84da39449014fc5ac0939d27fa12 100644 |
| --- a/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc |
| +++ b/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc |
| @@ -779,5 +779,45 @@ TEST_F(NGBlockLayoutAlgorithmTest, PositionFragmentsWithClear) { |
| EXPECT_EQ(kDiv1Size + kDiv2Size, child3->TopOffset()); |
| } |
| +// Verifies that we compute the right min and max-content size. |
| +TEST_F(NGBlockLayoutAlgorithmTest, ComputeMinMaxContent) { |
| + const int kWidth = 30; |
| + const int kHeight1 = 20; |
| + const int kHeight2 = 30; |
| + const int kMarginTop = 5; |
| + const int kMarginBottom = 20; |
| + style_->setWidth(Length(kWidth, Fixed)); |
|
ikilpatrick
2016/12/22 03:29:18
shouldn't this be fit-content or similar to trigge
cbiesinger
2016/12/22 15:22:32
Er, oops, I think I forgot to edit this after copy
|
| + |
| + RefPtr<ComputedStyle> first_style = ComputedStyle::create(); |
| + first_style->setHeight(Length(kHeight1, Fixed)); |
| + NGBlockNode* first_child = new NGBlockNode(first_style.get()); |
| + |
| + RefPtr<ComputedStyle> second_style = ComputedStyle::create(); |
| + second_style->setHeight(Length(kHeight2, Fixed)); |
| + second_style->setMarginTop(Length(kMarginTop, Fixed)); |
| + second_style->setMarginBottom(Length(kMarginBottom, Fixed)); |
| + NGBlockNode* second_child = new NGBlockNode(second_style.get()); |
| + |
| + first_child->SetNextSibling(second_child); |
| + |
| + auto* space = ConstructConstraintSpace( |
| + kHorizontalTopBottom, TextDirection::Ltr, |
| + NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); |
| + NGPhysicalFragment* frag = RunBlockLayoutAlgorithm(space, first_child); |
| + |
| + EXPECT_EQ(LayoutUnit(kWidth), frag->Width()); |
| + EXPECT_EQ(LayoutUnit(kHeight1 + kHeight2 + kMarginTop), frag->Height()); |
| + EXPECT_EQ(NGPhysicalFragmentBase::kFragmentBox, frag->Type()); |
| + ASSERT_EQ(frag->Children().size(), 2UL); |
| + |
| + const NGPhysicalFragmentBase* child = frag->Children()[0]; |
| + EXPECT_EQ(kHeight1, child->Height()); |
| + EXPECT_EQ(0, child->TopOffset()); |
| + |
| + child = frag->Children()[1]; |
| + EXPECT_EQ(kHeight2, child->Height()); |
| + EXPECT_EQ(kHeight1 + kMarginTop, child->TopOffset()); |
| +} |
| + |
| } // namespace |
| } // namespace blink |