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_iterator.h" | |
8 #include "core/layout/ng/ng_constraint_space.h" | 7 #include "core/layout/ng/ng_constraint_space.h" |
9 #include "core/layout/ng/ng_fragment.h" | 8 #include "core/layout/ng/ng_fragment.h" |
10 #include "core/layout/ng/ng_length_utils.h" | 9 #include "core/layout/ng/ng_length_utils.h" |
11 #include "core/style/ComputedStyle.h" | 10 #include "core/style/ComputedStyle.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
13 | 12 |
14 namespace blink { | 13 namespace blink { |
15 namespace { | 14 namespace { |
16 | 15 |
17 class NGBlockLayoutAlgorithmTest : public ::testing::Test { | 16 class NGBlockLayoutAlgorithmTest : public ::testing::Test { |
18 protected: | 17 protected: |
19 void SetUp() override { style_ = ComputedStyle::create(); } | 18 void SetUp() override { style_ = ComputedStyle::create(); } |
20 | 19 |
21 RefPtr<ComputedStyle> style_; | 20 RefPtr<ComputedStyle> style_; |
22 }; | 21 }; |
23 | 22 |
24 TEST_F(NGBlockLayoutAlgorithmTest, FixedSize) { | 23 TEST_F(NGBlockLayoutAlgorithmTest, FixedSize) { |
25 style_->setWidth(Length(30, Fixed)); | 24 style_->setWidth(Length(30, Fixed)); |
26 style_->setHeight(Length(40, Fixed)); | 25 style_->setHeight(Length(40, Fixed)); |
27 | 26 |
28 NGConstraintSpace* space = new NGConstraintSpace( | 27 NGConstraintSpace* space = new NGConstraintSpace( |
29 HorizontalTopBottom, NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); | 28 HorizontalTopBottom, NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); |
30 | 29 |
31 NGBlockLayoutAlgorithm algorithm(style_, NGBoxIterator(NGBox())); | 30 NGBlockLayoutAlgorithm algorithm(style_, nullptr); |
32 NGFragment* frag; | 31 NGFragment* frag; |
33 while (!algorithm.Layout(space, &frag)) | 32 while (!algorithm.Layout(space, &frag)) |
34 ; | 33 ; |
35 EXPECT_EQ(frag->InlineSize(), LayoutUnit(30)); | 34 EXPECT_EQ(frag->InlineSize(), LayoutUnit(30)); |
36 EXPECT_EQ(frag->BlockSize(), LayoutUnit(40)); | 35 EXPECT_EQ(frag->BlockSize(), LayoutUnit(40)); |
37 } | 36 } |
38 | 37 |
39 } // namespace | 38 } // namespace |
40 } // namespace blink | 39 } // namespace blink |
OLD | NEW |