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_block_node.h" | 7 #include "core/layout/ng/ng_block_node.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_constraint_space_builder.h" | 9 #include "core/layout/ng/ng_constraint_space_builder.h" |
10 #include "core/layout/ng/ng_layout_coordinator.h" | 10 #include "core/layout/ng/ng_layout_coordinator.h" |
11 #include "core/layout/ng/ng_length_utils.h" | 11 #include "core/layout/ng/ng_length_utils.h" |
12 #include "core/layout/ng/ng_physical_box_fragment.h" | 12 #include "core/layout/ng/ng_physical_box_fragment.h" |
13 #include "core/layout/ng/ng_physical_fragment.h" | 13 #include "core/layout/ng/ng_physical_fragment.h" |
14 #include "core/layout/ng/ng_units.h" | 14 #include "core/layout/ng/ng_units.h" |
| 15 #include "core/layout/LayoutTestHelper.h" |
15 #include "core/style/ComputedStyle.h" | 16 #include "core/style/ComputedStyle.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 | 18 |
18 namespace blink { | 19 namespace blink { |
19 namespace { | 20 namespace { |
20 | 21 |
21 NGConstraintSpace* ConstructConstraintSpace(NGWritingMode writing_mode, | 22 NGConstraintSpace* ConstructConstraintSpace(NGWritingMode writing_mode, |
22 TextDirection direction, | 23 TextDirection direction, |
23 NGLogicalSize size, | 24 NGLogicalSize size, |
24 bool shrink_to_fit = false) { | 25 bool shrink_to_fit = false) { |
25 return NGConstraintSpaceBuilder(writing_mode) | 26 return NGConstraintSpaceBuilder(writing_mode) |
26 .SetAvailableSize(size) | 27 .SetAvailableSize(size) |
27 .SetPercentageResolutionSize(size) | 28 .SetPercentageResolutionSize(size) |
28 .SetTextDirection(direction) | 29 .SetTextDirection(direction) |
29 .SetWritingMode(writing_mode) | 30 .SetWritingMode(writing_mode) |
30 .SetIsShrinkToFit(shrink_to_fit) | 31 .SetIsShrinkToFit(shrink_to_fit) |
31 .ToConstraintSpace(); | 32 .ToConstraintSpace(); |
32 } | 33 } |
33 | 34 |
34 class NGBlockLayoutAlgorithmTest : public ::testing::Test { | 35 typedef bool TestParamLayoutNG; |
| 36 class NGBlockLayoutAlgorithmTest |
| 37 : public ::testing::WithParamInterface<TestParamLayoutNG>, |
| 38 public RenderingTest { |
| 39 public: |
| 40 NGBlockLayoutAlgorithmTest() {} |
| 41 |
35 protected: | 42 protected: |
36 void SetUp() override { style_ = ComputedStyle::create(); } | 43 void SetUp() override { |
| 44 style_ = ComputedStyle::create(); |
| 45 RenderingTest::SetUp(); |
| 46 enableCompositing(); |
| 47 } |
37 | 48 |
38 NGPhysicalBoxFragment* RunBlockLayoutAlgorithm(NGConstraintSpace* space, | 49 NGPhysicalBoxFragment* RunBlockLayoutAlgorithm(NGConstraintSpace* space, |
39 NGBlockNode* first_child) { | 50 NGBlockNode* first_child) { |
40 NGBlockNode parent(style_.get()); | 51 NGBlockNode parent(style_.get()); |
41 parent.SetFirstChild(first_child); | 52 parent.SetFirstChild(first_child); |
42 | 53 |
43 NGBlockLayoutAlgorithm algorithm(style_.get(), first_child, space); | 54 NGBlockLayoutAlgorithm algorithm(style_.get(), first_child, space); |
44 | 55 |
45 NGPhysicalFragment* fragment; | 56 NGPhysicalFragment* fragment; |
46 NGLayoutAlgorithm* not_used; | 57 NGLayoutAlgorithm* not_used; |
(...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1551 EXPECT_EQ(LayoutUnit(194), fragment->LeftOffset()); | 1562 EXPECT_EQ(LayoutUnit(194), fragment->LeftOffset()); |
1552 EXPECT_EQ(LayoutUnit(), fragment->TopOffset()); | 1563 EXPECT_EQ(LayoutUnit(), fragment->TopOffset()); |
1553 EXPECT_EQ(LayoutUnit(16), fragment->Width()); | 1564 EXPECT_EQ(LayoutUnit(16), fragment->Width()); |
1554 EXPECT_EQ(LayoutUnit(50), fragment->Height()); | 1565 EXPECT_EQ(LayoutUnit(50), fragment->Height()); |
1555 EXPECT_EQ(0UL, fragment->Children().size()); | 1566 EXPECT_EQ(0UL, fragment->Children().size()); |
1556 EXPECT_FALSE(iterator.NextChild()); | 1567 EXPECT_FALSE(iterator.NextChild()); |
1557 } | 1568 } |
1558 | 1569 |
1559 } // namespace | 1570 } // namespace |
1560 } // namespace blink | 1571 } // namespace blink |
OLD | NEW |