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

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

Issue 2289353002: [layoutng] Add methods to compute border and padding (Closed)
Patch Set: Created 4 years, 3 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
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_derived_constraint_space.h" 8 #include "core/layout/ng/ng_derived_constraint_space.h"
9 #include "core/layout/ng/ng_margin_strut.h" 9 #include "core/layout/ng/ng_margin_strut.h"
10 #include "core/style/ComputedStyle.h" 10 #include "core/style/ComputedStyle.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 NGConstraintSpace* constraintSpace(ConstructConstraintSpace(200, 300)); 186 NGConstraintSpace* constraintSpace(ConstructConstraintSpace(200, 300));
187 187
188 NGBoxStrut margins = computeMargins(*constraintSpace, *style_); 188 NGBoxStrut margins = computeMargins(*constraintSpace, *style_);
189 189
190 EXPECT_EQ(LayoutUnit(20), margins.block_start); 190 EXPECT_EQ(LayoutUnit(20), margins.block_start);
191 EXPECT_EQ(LayoutUnit(52), margins.inline_end); 191 EXPECT_EQ(LayoutUnit(52), margins.inline_end);
192 EXPECT_EQ(LayoutUnit(), margins.block_end); 192 EXPECT_EQ(LayoutUnit(), margins.block_end);
193 EXPECT_EQ(LayoutUnit(22), margins.inline_start); 193 EXPECT_EQ(LayoutUnit(22), margins.inline_start);
194 } 194 }
195 195
196 TEST_F(NGLengthUtilsTest, testBorders) {
197 style_->setBorderTopWidth(1);
198 style_->setBorderRightWidth(2);
199 style_->setBorderBottomWidth(3);
200 style_->setBorderLeftWidth(4);
201 style_->setBorderTopStyle(BorderStyleSolid);
202 style_->setBorderRightStyle(BorderStyleSolid);
203 style_->setBorderBottomStyle(BorderStyleSolid);
204 style_->setBorderLeftStyle(BorderStyleSolid);
205 style_->setWritingMode(LeftToRightWritingMode);
206
207 NGBoxStrut borders = computeBorders(*style_);
208
209 EXPECT_EQ(LayoutUnit(4), borders.block_start);
210 EXPECT_EQ(LayoutUnit(3), borders.inline_end);
211 EXPECT_EQ(LayoutUnit(2), borders.block_end);
212 EXPECT_EQ(LayoutUnit(1), borders.inline_start);
213 }
214
215 TEST_F(NGLengthUtilsTest, testPadding) {
216 style_->setPaddingTop(Length(10, Percent));
217 style_->setPaddingRight(Length(52, Fixed));
Gleb Lanbin 2016/08/30 20:18:34 .nit it's better to use constants.
cbiesinger 2016/08/30 20:19:54 To use the same constant for the setting and testi
218 style_->setPaddingBottom(Length(Auto));
219 style_->setPaddingLeft(Length(11, Percent));
220 style_->setWritingMode(RightToLeftWritingMode);
221
222 NGConstraintSpace* constraintSpace(ConstructConstraintSpace(200, 300));
223
224 NGBoxStrut padding = computePadding(*constraintSpace, *style_);
225
226 EXPECT_EQ(LayoutUnit(52), padding.block_start);
227 EXPECT_EQ(LayoutUnit(), padding.inline_end);
228 EXPECT_EQ(LayoutUnit(22), padding.block_end);
229 EXPECT_EQ(LayoutUnit(20), padding.inline_start);
230 }
231
196 } // namespace 232 } // namespace
197 } // namespace blink 233 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698