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

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

Issue 2368153003: Compute margin block start for 1st block in LayoutNG root constraint space (Closed)
Patch Set: 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
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"
11 #include "core/layout/ng/ng_units.h" 11 #include "core/layout/ng/ng_units.h"
12 #include "core/style/ComputedStyle.h" 12 #include "core/style/ComputedStyle.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace blink { 15 namespace blink {
16 namespace { 16 namespace {
17 17
18 class NGBlockLayoutAlgorithmTest : public ::testing::Test { 18 class NGBlockLayoutAlgorithmTest : public ::testing::Test {
19 protected: 19 protected:
20 void SetUp() override { style_ = ComputedStyle::create(); } 20 void SetUp() override { style_ = ComputedStyle::create(); }
21 21
22 NGPhysicalFragment* RunBlockLayoutAlgorithm(const NGConstraintSpace* space, 22 NGPhysicalFragment* RunBlockLayoutAlgorithm(NGConstraintSpace* space,
23 NGBox* first_child) { 23 NGBox* first_child) {
24 NGBlockLayoutAlgorithm algorithm(style_, first_child); 24 NGBlockLayoutAlgorithm algorithm(style_, first_child);
25 NGPhysicalFragment* frag; 25 NGPhysicalFragment* frag;
26 space->SetIsRoot();
26 while (!algorithm.Layout(space, &frag)) 27 while (!algorithm.Layout(space, &frag))
27 continue; 28 continue;
28 return frag; 29 return frag;
29 } 30 }
30 31
31 RefPtr<ComputedStyle> style_; 32 RefPtr<ComputedStyle> style_;
32 }; 33 };
33 34
34 TEST_F(NGBlockLayoutAlgorithmTest, FixedSize) { 35 TEST_F(NGBlockLayoutAlgorithmTest, FixedSize) {
35 style_->setWidth(Length(30, Fixed)); 36 style_->setWidth(Length(30, Fixed));
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 482
482 EXPECT_EQ(frag->Width(), LayoutUnit(kWidth + kPaddingLeft)); 483 EXPECT_EQ(frag->Width(), LayoutUnit(kWidth + kPaddingLeft));
483 EXPECT_EQ(frag->Type(), NGPhysicalFragmentBase::FragmentBox); 484 EXPECT_EQ(frag->Type(), NGPhysicalFragmentBase::FragmentBox);
484 ASSERT_EQ(frag->Children().size(), 1UL); 485 ASSERT_EQ(frag->Children().size(), 1UL);
485 486
486 const NGPhysicalFragmentBase* child = frag->Children()[0]; 487 const NGPhysicalFragmentBase* child = frag->Children()[0];
487 EXPECT_EQ(child->Width(), LayoutUnit(12)); 488 EXPECT_EQ(child->Width(), LayoutUnit(12));
488 } 489 }
489 } // namespace 490 } // namespace
490 } // namespace blink 491 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698