| 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_length_utils.h" | 5 #include "core/layout/ng/ng_length_utils.h" |
| 6 | 6 |
| 7 #include "core/layout/ng/ng_constraint_space.h" | 7 #include "core/layout/ng/ng_constraint_space.h" |
| 8 #include "core/layout/ng/ng_margin_strut.h" |
| 8 #include "core/style/ComputedStyle.h" | 9 #include "core/style/ComputedStyle.h" |
| 9 #include "platform/CalculationValue.h" | 10 #include "platform/CalculationValue.h" |
| 10 #include "platform/LayoutUnit.h" | 11 #include "platform/LayoutUnit.h" |
| 11 #include "platform/Length.h" | 12 #include "platform/Length.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "wtf/RefPtr.h" | 14 #include "wtf/RefPtr.h" |
| 14 | 15 |
| 15 namespace blink { | 16 namespace blink { |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 style_->setMaxHeight(Length(80, Percent)); | 152 style_->setMaxHeight(Length(80, Percent)); |
| 152 EXPECT_EQ(LayoutUnit(240), computeBlockSizeForFragment()); | 153 EXPECT_EQ(LayoutUnit(240), computeBlockSizeForFragment()); |
| 153 | 154 |
| 154 style_->setLogicalHeight(Length(100, Fixed)); | 155 style_->setLogicalHeight(Length(100, Fixed)); |
| 155 style_->setMinHeight(Length(80, Percent)); | 156 style_->setMinHeight(Length(80, Percent)); |
| 156 EXPECT_EQ(LayoutUnit(240), computeBlockSizeForFragment()); | 157 EXPECT_EQ(LayoutUnit(240), computeBlockSizeForFragment()); |
| 157 | 158 |
| 158 // TODO(layout-ng): test {min,max}-content on max-height. | 159 // TODO(layout-ng): test {min,max}-content on max-height. |
| 159 } | 160 } |
| 160 | 161 |
| 162 TEST_F(NGLengthUtilsTest, testMargins) { |
| 163 style_->setMarginTop(Length(10, Percent)); |
| 164 style_->setMarginRight(Length(52, Fixed)); |
| 165 style_->setMarginBottom(Length(Auto)); |
| 166 style_->setMarginLeft(Length(11, Percent)); |
| 167 |
| 168 NGConstraintSpace constraintSpace(constructConstraintSpace(200, 300)); |
| 169 |
| 170 NGBoxMargins margins = computeMargins(constraintSpace, *style_); |
| 171 |
| 172 EXPECT_EQ(LayoutUnit(20), margins.blockStart); |
| 173 EXPECT_EQ(LayoutUnit(52), margins.inlineEnd); |
| 174 EXPECT_EQ(LayoutUnit(), margins.blockEnd); |
| 175 EXPECT_EQ(LayoutUnit(22), margins.inlineStart); |
| 176 } |
| 177 |
| 161 } // namespace | 178 } // namespace |
| 162 } // namespace blink | 179 } // namespace blink |
| OLD | NEW |