Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/ng_length_utils_test.cc

Issue 2346403002: [layoutng] Create correct constraint spaces for children (Closed)
Patch Set: fix assert failures Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_length_utils.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_units.h" 8 #include "core/layout/ng/ng_units.h"
9 #include "core/style/ComputedStyle.h" 9 #include "core/style/ComputedStyle.h"
10 #include "platform/CalculationValue.h" 10 #include "platform/CalculationValue.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 style_->setMarginRight(Length(20, Fixed)); 127 style_->setMarginRight(Length(20, Fixed));
128 EXPECT_EQ(LayoutUnit(180), computeInlineSizeForFragment()); 128 EXPECT_EQ(LayoutUnit(180), computeInlineSizeForFragment());
129 129
130 style_->setLogicalWidth(Length(100, Fixed)); 130 style_->setLogicalWidth(Length(100, Fixed));
131 style_->setPaddingLeft(Length(50, Fixed)); 131 style_->setPaddingLeft(Length(50, Fixed));
132 EXPECT_EQ(LayoutUnit(150), computeInlineSizeForFragment()); 132 EXPECT_EQ(LayoutUnit(150), computeInlineSizeForFragment());
133 133
134 style_->setBoxSizing(BoxSizingBorderBox); 134 style_->setBoxSizing(BoxSizingBorderBox);
135 EXPECT_EQ(LayoutUnit(100), computeInlineSizeForFragment()); 135 EXPECT_EQ(LayoutUnit(100), computeInlineSizeForFragment());
136 136
137 // Content size should never be below zero, even with box-sizing: border-box
138 // and a large padding...
139 style_->setPaddingLeft(Length(400, Fixed));
140 EXPECT_EQ(LayoutUnit(400), computeInlineSizeForFragment());
141
142 // ...and the same goes for fill-available with a large padding.
143 style_->setLogicalWidth(Length(FillAvailable));
144 EXPECT_EQ(LayoutUnit(400), computeInlineSizeForFragment());
145
137 // TODO(layout-ng): test {min,max}-content on max-width. 146 // TODO(layout-ng): test {min,max}-content on max-width.
138 } 147 }
139 148
140 TEST_F(NGLengthUtilsTest, testComputeBlockSizeForFragment) { 149 TEST_F(NGLengthUtilsTest, testComputeBlockSizeForFragment) {
141 style_->setLogicalHeight(Length(30, Percent)); 150 style_->setLogicalHeight(Length(30, Percent));
142 EXPECT_EQ(LayoutUnit(90), computeBlockSizeForFragment()); 151 EXPECT_EQ(LayoutUnit(90), computeBlockSizeForFragment());
143 152
144 style_->setLogicalHeight(Length(150, Fixed)); 153 style_->setLogicalHeight(Length(150, Fixed));
145 EXPECT_EQ(LayoutUnit(150), computeBlockSizeForFragment()); 154 EXPECT_EQ(LayoutUnit(150), computeBlockSizeForFragment());
146 155
(...skipping 30 matching lines...) Expand all
177 style_->setLogicalHeight(Length(FillAvailable)); 186 style_->setLogicalHeight(Length(FillAvailable));
178 EXPECT_EQ(LayoutUnit(280), computeBlockSizeForFragment()); 187 EXPECT_EQ(LayoutUnit(280), computeBlockSizeForFragment());
179 188
180 style_->setLogicalHeight(Length(100, Fixed)); 189 style_->setLogicalHeight(Length(100, Fixed));
181 style_->setPaddingBottom(Length(50, Fixed)); 190 style_->setPaddingBottom(Length(50, Fixed));
182 EXPECT_EQ(LayoutUnit(150), computeBlockSizeForFragment()); 191 EXPECT_EQ(LayoutUnit(150), computeBlockSizeForFragment());
183 192
184 style_->setBoxSizing(BoxSizingBorderBox); 193 style_->setBoxSizing(BoxSizingBorderBox);
185 EXPECT_EQ(LayoutUnit(100), computeBlockSizeForFragment()); 194 EXPECT_EQ(LayoutUnit(100), computeBlockSizeForFragment());
186 195
196 // Content size should never be below zero, even with box-sizing: border-box
197 // and a large padding...
198 style_->setPaddingBottom(Length(400, Fixed));
199 EXPECT_EQ(LayoutUnit(400), computeBlockSizeForFragment());
200
201 // ...and the same goes for fill-available with a large padding.
202 style_->setLogicalHeight(Length(FillAvailable));
203 EXPECT_EQ(LayoutUnit(400), computeBlockSizeForFragment());
204
187 // TODO(layout-ng): test {min,max}-content on max-height. 205 // TODO(layout-ng): test {min,max}-content on max-height.
188 } 206 }
189 207
190 TEST_F(NGLengthUtilsTest, testIndefinitePercentages) { 208 TEST_F(NGLengthUtilsTest, testIndefinitePercentages) {
191 style_->setMinHeight(Length(20, Fixed)); 209 style_->setMinHeight(Length(20, Fixed));
192 style_->setHeight(Length(20, Percent)); 210 style_->setHeight(Length(20, Percent));
193 211
194 EXPECT_EQ(NGSizeIndefinite, 212 EXPECT_EQ(NGSizeIndefinite,
195 computeBlockSizeForFragment(ConstructConstraintSpace(200, -1), 213 computeBlockSizeForFragment(ConstructConstraintSpace(200, -1),
196 LayoutUnit(-1))); 214 LayoutUnit(-1)));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 NGBoxStrut padding = computePadding(*constraintSpace, *style_); 268 NGBoxStrut padding = computePadding(*constraintSpace, *style_);
251 269
252 EXPECT_EQ(LayoutUnit(52), padding.block_start); 270 EXPECT_EQ(LayoutUnit(52), padding.block_start);
253 EXPECT_EQ(LayoutUnit(), padding.inline_end); 271 EXPECT_EQ(LayoutUnit(), padding.inline_end);
254 EXPECT_EQ(LayoutUnit(22), padding.block_end); 272 EXPECT_EQ(LayoutUnit(22), padding.block_end);
255 EXPECT_EQ(LayoutUnit(20), padding.inline_start); 273 EXPECT_EQ(LayoutUnit(20), padding.inline_start);
256 } 274 }
257 275
258 } // namespace 276 } // namespace
259 } // namespace blink 277 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_length_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698