| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/layout/ng/ng_block_layout_algorithm.h" | 5 #include "core/layout/ng/ng_block_layout_algorithm.h" |
| 6 | 6 |
| 7 #include "core/layout/ng/ng_box.h" | 7 #include "core/layout/ng/ng_box.h" |
| 8 #include "core/layout/ng/ng_constraint_space.h" | 8 #include "core/layout/ng/ng_constraint_space.h" |
| 9 #include "core/layout/ng/ng_physical_fragment.h" | 9 #include "core/layout/ng/ng_physical_fragment.h" |
| 10 #include "core/layout/ng/ng_length_utils.h" | 10 #include "core/layout/ng/ng_length_utils.h" |
| 11 #include "core/layout/ng/ng_units.h" | 11 #include "core/layout/ng/ng_units.h" |
| 12 #include "core/style/ComputedStyle.h" | 12 #include "core/style/ComputedStyle.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 NGConstraintSpace* ConstructConstraintSpace(NGWritingMode writing_mode, | 18 NGConstraintSpace* ConstructConstraintSpace(NGWritingMode writing_mode, |
| 19 NGDirection direction, | 19 NGDirection direction, |
| 20 NGPhysicalSize size) { | 20 NGPhysicalSize size) { |
| 21 return new NGConstraintSpace(writing_mode, direction, | 21 return new NGConstraintSpace(writing_mode, direction, |
| 22 new NGPhysicalConstraintSpace(size)); | 22 new NGPhysicalConstraintSpace(size)); |
| 23 } | 23 } |
| 24 | 24 |
| 25 class NGBlockLayoutAlgorithmTest : public ::testing::Test { | 25 class NGBlockLayoutAlgorithmTest : public ::testing::Test { |
| 26 protected: | 26 protected: |
| 27 void SetUp() override { style_ = ComputedStyle::create(); } | 27 void SetUp() override { style_ = ComputedStyle::create(); } |
| 28 | 28 |
| 29 NGPhysicalFragment* RunBlockLayoutAlgorithm(const NGConstraintSpace* space, | 29 NGPhysicalFragment* RunBlockLayoutAlgorithm(NGConstraintSpace* space, |
| 30 NGBox* first_child) { | 30 NGBox* first_child) { |
| 31 NGBlockLayoutAlgorithm algorithm(style_, first_child); | 31 NGBlockLayoutAlgorithm algorithm(style_, first_child, space); |
| 32 NGPhysicalFragment* frag; | 32 NGPhysicalFragment* frag; |
| 33 while (!algorithm.Layout(space, &frag)) | 33 while (!algorithm.Layout(&frag)) |
| 34 continue; | 34 continue; |
| 35 return frag; | 35 return frag; |
| 36 } | 36 } |
| 37 | 37 |
| 38 RefPtr<ComputedStyle> style_; | 38 RefPtr<ComputedStyle> style_; |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 TEST_F(NGBlockLayoutAlgorithmTest, FixedSize) { | 41 TEST_F(NGBlockLayoutAlgorithmTest, FixedSize) { |
| 42 style_->setWidth(Length(30, Fixed)); | 42 style_->setWidth(Length(30, Fixed)); |
| 43 style_->setHeight(Length(40, Fixed)); | 43 style_->setHeight(Length(40, Fixed)); |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 EXPECT_EQ(0, child2->TopOffset()); | 659 EXPECT_EQ(0, child2->TopOffset()); |
| 660 EXPECT_EQ(kParentSize - kDiv2Size, child2->LeftOffset()); | 660 EXPECT_EQ(kParentSize - kDiv2Size, child2->LeftOffset()); |
| 661 | 661 |
| 662 // DIV3 | 662 // DIV3 |
| 663 const NGPhysicalFragmentBase* child3 = frag->Children()[2]; | 663 const NGPhysicalFragmentBase* child3 = frag->Children()[2]; |
| 664 EXPECT_EQ(kDiv2Size, child3->TopOffset()); | 664 EXPECT_EQ(kDiv2Size, child3->TopOffset()); |
| 665 EXPECT_EQ(kDiv3LeftMargin, child3->LeftOffset()); | 665 EXPECT_EQ(kDiv3LeftMargin, child3->LeftOffset()); |
| 666 } | 666 } |
| 667 } // namespace | 667 } // namespace |
| 668 } // namespace blink | 668 } // namespace blink |
| OLD | NEW |