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

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

Issue 2346403002: [layoutng] Create correct constraint spaces for children (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_block_layout_algorithm.h" 5 #include "core/layout/ng/ng_block_layout_algorithm.h"
6 6
7 #include "core/layout/ng/ng_box.h" 7 #include "core/layout/ng/ng_box.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_physical_fragment.h" 9 #include "core/layout/ng/ng_physical_fragment.h"
10 #include "core/layout/ng/ng_length_utils.h" 10 #include "core/layout/ng/ng_length_utils.h"
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 395
396 ASSERT_TRUE(child->Type() == NGPhysicalFragmentBase::FragmentBox); 396 ASSERT_TRUE(child->Type() == NGPhysicalFragmentBase::FragmentBox);
397 ASSERT_EQ(static_cast<const NGPhysicalFragment*>(child)->Children().size(), 397 ASSERT_EQ(static_cast<const NGPhysicalFragment*>(child)->Children().size(),
398 1UL); 398 1UL);
399 399
400 // div2 400 // div2
401 child = static_cast<const NGPhysicalFragment*>(child)->Children()[0]; 401 child = static_cast<const NGPhysicalFragment*>(child)->Children()[0];
402 EXPECT_EQ(kBorderTop + kPaddingTop, child->TopOffset()); 402 EXPECT_EQ(kBorderTop + kPaddingTop, child->TopOffset());
403 EXPECT_EQ(kBorderLeft + kPaddingLeft, child->LeftOffset()); 403 EXPECT_EQ(kBorderLeft + kPaddingLeft, child->LeftOffset());
404 } 404 }
405
406 TEST_F(NGBlockLayoutAlgorithmTest, PercentageSize) {
407 const int kPaddingLeft = 10;
408 const int kWidth = 30;
409 style_->setWidth(Length(kWidth, Fixed));
410 style_->setPaddingLeft(Length(kPaddingLeft, Fixed));
411
412 RefPtr<ComputedStyle> first_style = ComputedStyle::create();
413 first_style->setWidth(Length(40, Percent));
414 NGBox* first_child = new NGBox(first_style.get());
415
416 auto* space =
417 new NGConstraintSpace(HorizontalTopBottom, LeftToRight,
418 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite));
419 NGPhysicalFragment* frag = RunBlockLayoutAlgorithm(space, first_child);
420
421 EXPECT_EQ(frag->Width(), LayoutUnit(kWidth + kPaddingLeft));
422 EXPECT_EQ(frag->Type(), NGPhysicalFragmentBase::FragmentBox);
423 ASSERT_EQ(frag->Children().size(), 1UL);
424
425 const NGPhysicalFragmentBase* child = frag->Children()[0];
426 EXPECT_EQ(child->Width(), LayoutUnit(12));
eae 2016/09/20 08:09:38 You might want an EXPECT_EQ(frag->Children().size(
cbiesinger 2016/09/20 13:43:37 There's already an ASSERT_EQ for that above.
427 }
405 } // namespace 428 } // namespace
406 } // namespace blink 429 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698