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

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

Issue 2298273002: Initial exclusion aware layout opportunities implementation (Closed)
Patch Set: Address reviewer comments 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_constraint_space.h" 5 #include "core/layout/ng/ng_constraint_space.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
(...skipping 24 matching lines...) Expand all
35 EXPECT_TRUE(horz_space->FixedInlineSize()); 35 EXPECT_TRUE(horz_space->FixedInlineSize());
36 EXPECT_TRUE(vert_space->FixedBlockSize()); 36 EXPECT_TRUE(vert_space->FixedBlockSize());
37 37
38 EXPECT_FALSE(horz_space->FixedBlockSize()); 38 EXPECT_FALSE(horz_space->FixedBlockSize());
39 EXPECT_FALSE(vert_space->FixedInlineSize()); 39 EXPECT_FALSE(vert_space->FixedInlineSize());
40 40
41 EXPECT_EQ(FragmentColumn, horz_space->BlockFragmentationType()); 41 EXPECT_EQ(FragmentColumn, horz_space->BlockFragmentationType());
42 EXPECT_EQ(FragmentNone, vert_space->BlockFragmentationType()); 42 EXPECT_EQ(FragmentNone, vert_space->BlockFragmentationType());
43 } 43 }
44 44
45 TEST(NGConstraintSpaceTest, LayoutOpportunities) { 45 TEST(NGConstraintSpaceTest, LayoutOpportunitiesNoExclusions) {
46 // TODO(eae): Implement in followup change. 46 NGPhysicalSize physical_size;
47 physical_size.width = LayoutUnit(600);
48 physical_size.height = LayoutUnit(400);
49 auto* physical_space = new NGPhysicalConstraintSpace(physical_size);
50 auto* space = new NGConstraintSpace(HorizontalTopBottom, physical_space);
51
52 bool for_inline_or_bfc = true;
53 auto* iterator = space->LayoutOpportunities(NGClearNone, for_inline_or_bfc);
54
55 const NGConstraintSpace* firstOpportunity = iterator->Next();
56 EXPECT_NE(nullptr, firstOpportunity);
57 EXPECT_EQ(LayoutUnit(600), firstOpportunity->Size().inline_size);
58 EXPECT_EQ(LayoutUnit(400), firstOpportunity->Size().block_size);
59
60 const NGConstraintSpace* secondOpportunity = iterator->Next();
61 EXPECT_EQ(nullptr, secondOpportunity);
62 }
63
64 TEST(NGConstraintSpaceTest, LayoutOpportunitiesOneExclusion) {
65 NGPhysicalSize physical_size;
66 physical_size.width = LayoutUnit(600);
67 physical_size.height = LayoutUnit(400);
68 auto* physical_space = new NGPhysicalConstraintSpace(physical_size);
69
70 // Add a 100x100 exclusion in the top right corner.
71 physical_space->AddExclusion(NGExclusion(LayoutUnit(0), LayoutUnit(600),
72 LayoutUnit(100), LayoutUnit(500)));
73
74 auto* space = new NGConstraintSpace(HorizontalTopBottom, physical_space);
75 bool for_inline_or_bfc = true;
76 auto* iterator = space->LayoutOpportunities(NGClearNone, for_inline_or_bfc);
77
78 // First opportunity should be to the left of the exclusion.
79 const NGConstraintSpace* firstOpportunity = iterator->Next();
80 EXPECT_NE(nullptr, firstOpportunity);
81 EXPECT_EQ(LayoutUnit(0), firstOpportunity->Offset().inline_offset);
82 EXPECT_EQ(LayoutUnit(0), firstOpportunity->Offset().block_offset);
83 EXPECT_EQ(LayoutUnit(500), firstOpportunity->Size().inline_size);
84 EXPECT_EQ(LayoutUnit(400), firstOpportunity->Size().block_size);
85
86 const NGConstraintSpace* secondOpportunity = iterator->Next();
87 EXPECT_EQ(nullptr, secondOpportunity);
47 } 88 }
48 89
49 } // namespace 90 } // namespace
50 91
51 } // namespace blink 92 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698