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

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

Issue 2451553005: Add NGLogicalOrigin and NGLogicalLeader parameters to NGLayoutOpportunityIterator. (Closed)
Patch Set: do not redefine default LayoutOpportunities parameters Created 4 years, 1 month 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 "core/layout/ng/ng_constraint_space.h" 7 #include "core/layout/ng/ng_constraint_space.h"
8 #include "core/layout/ng/ng_layout_opportunity_iterator.h" 8 #include "core/layout/ng/ng_layout_opportunity_iterator.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 } 50 }
51 51
52 TEST(NGConstraintSpaceTest, LayoutOpportunitiesNoExclusions) { 52 TEST(NGConstraintSpaceTest, LayoutOpportunitiesNoExclusions) {
53 NGPhysicalSize physical_size; 53 NGPhysicalSize physical_size;
54 physical_size.width = LayoutUnit(600); 54 physical_size.width = LayoutUnit(600);
55 physical_size.height = LayoutUnit(400); 55 physical_size.height = LayoutUnit(400);
56 auto* physical_space = new NGPhysicalConstraintSpace(physical_size); 56 auto* physical_space = new NGPhysicalConstraintSpace(physical_size);
57 auto* space = 57 auto* space =
58 new NGConstraintSpace(HorizontalTopBottom, LeftToRight, physical_space); 58 new NGConstraintSpace(HorizontalTopBottom, LeftToRight, physical_space);
59 59
60 bool for_inline_or_bfc = true; 60 auto* iterator = space->LayoutOpportunities();
61 auto* iterator = space->LayoutOpportunities(NGClearNone, for_inline_or_bfc);
62 61
63 EXPECT_EQ("0,0 600x400", OpportunityToString(iterator->Next())); 62 EXPECT_EQ("0,0 600x400", OpportunityToString(iterator->Next()));
64 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next())); 63 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next()));
65 } 64 }
66 65
67 TEST(NGConstraintSpaceTest, LayoutOpportunitiesTopRightExclusion) { 66 TEST(NGConstraintSpaceTest, LayoutOpportunitiesTopRightExclusion) {
68 NGPhysicalSize physical_size; 67 NGPhysicalSize physical_size;
69 physical_size.width = LayoutUnit(600); 68 physical_size.width = LayoutUnit(600);
70 physical_size.height = LayoutUnit(400); 69 physical_size.height = LayoutUnit(400);
71 auto* physical_space = new NGPhysicalConstraintSpace(physical_size); 70 auto* physical_space = new NGPhysicalConstraintSpace(physical_size);
72 71
73 // Add a 100x100 exclusion in the top right corner. 72 // Add a 100x100 exclusion in the top right corner.
74 physical_space->AddExclusion(new NGExclusion( 73 physical_space->AddExclusion(new NGExclusion(
75 LayoutUnit(0), LayoutUnit(600), LayoutUnit(100), LayoutUnit(500))); 74 LayoutUnit(0), LayoutUnit(600), LayoutUnit(100), LayoutUnit(500)));
76 75
77 auto* space = 76 auto* space =
78 new NGConstraintSpace(HorizontalTopBottom, LeftToRight, physical_space); 77 new NGConstraintSpace(HorizontalTopBottom, LeftToRight, physical_space);
79 bool for_inline_or_bfc = true; 78 auto* iterator = space->LayoutOpportunities();
80 auto* iterator = space->LayoutOpportunities(NGClearNone, for_inline_or_bfc);
81 79
82 // First opportunity should be to the left of the exclusion. 80 // First opportunity should be to the left of the exclusion.
83 EXPECT_EQ("0,0 500x400", OpportunityToString(iterator->Next())); 81 EXPECT_EQ("0,0 500x400", OpportunityToString(iterator->Next()));
84 82
85 // Second opportunity should be below the exclusion. 83 // Second opportunity should be below the exclusion.
86 EXPECT_EQ("0,100 600x300", OpportunityToString(iterator->Next())); 84 EXPECT_EQ("0,100 600x300", OpportunityToString(iterator->Next()));
87 85
88 // There should be no third opportunity. 86 // There should be no third opportunity.
89 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next())); 87 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next()));
90 } 88 }
91 89
92 TEST(NGConstraintSpaceTest, LayoutOpportunitiesTopLeftExclusion) { 90 TEST(NGConstraintSpaceTest, LayoutOpportunitiesTopLeftExclusion) {
93 NGPhysicalSize physical_size; 91 NGPhysicalSize physical_size;
94 physical_size.width = LayoutUnit(600); 92 physical_size.width = LayoutUnit(600);
95 physical_size.height = LayoutUnit(400); 93 physical_size.height = LayoutUnit(400);
96 auto* physical_space = new NGPhysicalConstraintSpace(physical_size); 94 auto* physical_space = new NGPhysicalConstraintSpace(physical_size);
97 95
98 // Add a 100x100 exclusion in the top left corner. 96 // Add a 100x100 exclusion in the top left corner.
99 physical_space->AddExclusion(new NGExclusion(LayoutUnit(0), LayoutUnit(100), 97 physical_space->AddExclusion(new NGExclusion(LayoutUnit(0), LayoutUnit(100),
100 LayoutUnit(100), LayoutUnit(0))); 98 LayoutUnit(100), LayoutUnit(0)));
101 99
102 auto* space = 100 auto* space =
103 new NGConstraintSpace(HorizontalTopBottom, LeftToRight, physical_space); 101 new NGConstraintSpace(HorizontalTopBottom, LeftToRight, physical_space);
104 bool for_inline_or_bfc = true; 102 auto* iterator = space->LayoutOpportunities();
105 auto* iterator = space->LayoutOpportunities(NGClearNone, for_inline_or_bfc);
106 103
107 // First opportunity should be to the right of the exclusion. 104 // First opportunity should be to the right of the exclusion.
108 EXPECT_EQ("100,0 500x400", OpportunityToString(iterator->Next())); 105 EXPECT_EQ("100,0 500x400", OpportunityToString(iterator->Next()));
109 106
110 // Second opportunity should be below the exclusion. 107 // Second opportunity should be below the exclusion.
111 EXPECT_EQ("0,100 600x300", OpportunityToString(iterator->Next())); 108 EXPECT_EQ("0,100 600x300", OpportunityToString(iterator->Next()));
112 109
113 // There should be no third opportunity. 110 // There should be no third opportunity.
114 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next())); 111 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next()));
115 } 112 }
(...skipping 28 matching lines...) Expand all
144 auto* physical_space = new NGPhysicalConstraintSpace(physical_size); 141 auto* physical_space = new NGPhysicalConstraintSpace(physical_size);
145 142
146 // Add exclusions 143 // Add exclusions
147 physical_space->AddExclusion(new NGExclusion( 144 physical_space->AddExclusion(new NGExclusion(
148 LayoutUnit(200), LayoutUnit(250), LayoutUnit(300), LayoutUnit(150))); 145 LayoutUnit(200), LayoutUnit(250), LayoutUnit(300), LayoutUnit(150)));
149 physical_space->AddExclusion(new NGExclusion( 146 physical_space->AddExclusion(new NGExclusion(
150 LayoutUnit(350), LayoutUnit(550), LayoutUnit(400), LayoutUnit(500))); 147 LayoutUnit(350), LayoutUnit(550), LayoutUnit(400), LayoutUnit(500)));
151 148
152 auto* space = 149 auto* space =
153 new NGConstraintSpace(HorizontalTopBottom, LeftToRight, physical_space); 150 new NGConstraintSpace(HorizontalTopBottom, LeftToRight, physical_space);
154 bool for_inline_or_bfc = true; 151 auto* iterator = space->LayoutOpportunities();
155 auto* iterator = space->LayoutOpportunities(NGClearNone, for_inline_or_bfc);
156 152
157 // 1st Start point 153 // 1st Start point
158 EXPECT_EQ("0,0 600x200", OpportunityToString(iterator->Next())); 154 EXPECT_EQ("0,0 600x200", OpportunityToString(iterator->Next()));
159 EXPECT_EQ("0,0 150x400", OpportunityToString(iterator->Next())); 155 EXPECT_EQ("0,0 150x400", OpportunityToString(iterator->Next()));
160 156
161 // 2nd Start point 157 // 2nd Start point
162 EXPECT_EQ("250,0 350x350", OpportunityToString(iterator->Next())); 158 EXPECT_EQ("250,0 350x350", OpportunityToString(iterator->Next()));
163 EXPECT_EQ("250,0 250x400", OpportunityToString(iterator->Next())); 159 EXPECT_EQ("250,0 250x400", OpportunityToString(iterator->Next()));
164 160
165 // 3rd Start point 161 // 3rd Start point
(...skipping 26 matching lines...) Expand all
192 NGPhysicalSize physical_size; 188 NGPhysicalSize physical_size;
193 physical_size.width = LayoutUnit(600); 189 physical_size.width = LayoutUnit(600);
194 physical_size.height = LayoutUnit(100); 190 physical_size.height = LayoutUnit(100);
195 191
196 auto* physical_space = new NGPhysicalConstraintSpace(physical_size); 192 auto* physical_space = new NGPhysicalConstraintSpace(physical_size);
197 physical_space->AddExclusion(new NGExclusion(LayoutUnit(150), LayoutUnit(100), 193 physical_space->AddExclusion(new NGExclusion(LayoutUnit(150), LayoutUnit(100),
198 LayoutUnit(200), LayoutUnit(0))); 194 LayoutUnit(200), LayoutUnit(0)));
199 auto* space = 195 auto* space =
200 new NGConstraintSpace(HorizontalTopBottom, LeftToRight, physical_space); 196 new NGConstraintSpace(HorizontalTopBottom, LeftToRight, physical_space);
201 197
202 bool for_inline_or_bfc = true; 198 auto* iterator = space->LayoutOpportunities();
203 auto* iterator = space->LayoutOpportunities(NGClearNone, for_inline_or_bfc);
204 199
205 EXPECT_EQ("0,0 600x100", OpportunityToString(iterator->Next())); 200 EXPECT_EQ("0,0 600x100", OpportunityToString(iterator->Next()));
206 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next())); 201 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next()));
207 } 202 }
208 203
209 } // namespace 204 } // namespace
210 } // namespace blink 205 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698