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 class NGBlockLayoutAlgorithmTest : public ::testing::Test { | 18 class NGBlockLayoutAlgorithmTest : public ::testing::Test { |
19 protected: | 19 protected: |
20 void SetUp() override { style_ = ComputedStyle::create(); } | 20 void SetUp() override { style_ = ComputedStyle::create(); } |
21 | 21 |
22 NGPhysicalFragment* RunBlockLayoutAlgorithm(const NGConstraintSpace* space, | 22 NGPhysicalFragment* RunBlockLayoutAlgorithm(NGConstraintSpace* space, |
23 NGBox* first_child) { | 23 NGBox* first_child) { |
24 NGBlockLayoutAlgorithm algorithm(style_, first_child); | 24 NGBlockLayoutAlgorithm algorithm(style_, first_child); |
25 NGPhysicalFragment* frag; | 25 NGPhysicalFragment* frag; |
| 26 space->SetIsRoot(); |
26 while (!algorithm.Layout(space, &frag)) | 27 while (!algorithm.Layout(space, &frag)) |
27 continue; | 28 continue; |
28 return frag; | 29 return frag; |
29 } | 30 } |
30 | 31 |
31 RefPtr<ComputedStyle> style_; | 32 RefPtr<ComputedStyle> style_; |
32 }; | 33 }; |
33 | 34 |
34 TEST_F(NGBlockLayoutAlgorithmTest, FixedSize) { | 35 TEST_F(NGBlockLayoutAlgorithmTest, FixedSize) { |
35 style_->setWidth(Length(30, Fixed)); | 36 style_->setWidth(Length(30, Fixed)); |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 | 482 |
482 EXPECT_EQ(frag->Width(), LayoutUnit(kWidth + kPaddingLeft)); | 483 EXPECT_EQ(frag->Width(), LayoutUnit(kWidth + kPaddingLeft)); |
483 EXPECT_EQ(frag->Type(), NGPhysicalFragmentBase::FragmentBox); | 484 EXPECT_EQ(frag->Type(), NGPhysicalFragmentBase::FragmentBox); |
484 ASSERT_EQ(frag->Children().size(), 1UL); | 485 ASSERT_EQ(frag->Children().size(), 1UL); |
485 | 486 |
486 const NGPhysicalFragmentBase* child = frag->Children()[0]; | 487 const NGPhysicalFragmentBase* child = frag->Children()[0]; |
487 EXPECT_EQ(child->Width(), LayoutUnit(12)); | 488 EXPECT_EQ(child->Width(), LayoutUnit(12)); |
488 } | 489 } |
489 } // namespace | 490 } // namespace |
490 } // namespace blink | 491 } // namespace blink |
OLD | NEW |