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

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

Issue 2477843002: Revert of Add support of leader_point in NGLayoutOpportunityIterator. (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ng/ng_layout_opportunity_iterator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "core/layout/ng/ng_physical_constraint_space.h" 9 #include "core/layout/ng/ng_physical_constraint_space.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 190
191 // 4th Start point 191 // 4th Start point
192 EXPECT_EQ("0,300 600x50", OpportunityToString(iterator->Next())); 192 EXPECT_EQ("0,300 600x50", OpportunityToString(iterator->Next()));
193 EXPECT_EQ("0,300 500x100", OpportunityToString(iterator->Next())); 193 EXPECT_EQ("0,300 500x100", OpportunityToString(iterator->Next()));
194 194
195 // Iterator is exhausted. 195 // Iterator is exhausted.
196 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next())); 196 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next()));
197 } 197 }
198 198
199 // This test is the same as LayoutOpportunitiesTwoInMiddle with the only 199 // This test is the same as LayoutOpportunitiesTwoInMiddle with the only
200 // difference that NGLayoutOpportunityIterator takes 2 additional arguments: 200 // difference that NGLayoutOpportunityIterator takes the additional argument
201 // - origin_point that changes the iterator to return Layout Opportunities that 201 // origin_point that changes the iterator to return Layout Opportunities that
202 // lay after the origin point. 202 // lay after the origin point.
203 // - leader_point that together with origin_point creates a temporary exclusion
204 // 203 //
205 // Expected: 204 // Expected:
206 // Layout opportunity iterator generates the next opportunities: 205 // Layout opportunity iterator generates the next opportunities:
207 // - 1st Start Point (0, 200): 350x150, 250x200 206 // - 1st Start Point (0, 200): 150x200
207 // - 2nd Start Point (250, 200): 350x150, 250x200
208 // - 3rd Start Point (550, 200): 50x200 208 // - 3rd Start Point (550, 200): 50x200
209 // - 4th Start Point (0, 300): 600x50, 500x100 209 // - 4th Start Point (0, 300): 600x50, 500x100
210 // All other opportunities that are located before the origin point should be 210 // All other opportunities that are located before the origin point should be
211 // filtered out. 211 // filtered out.
212 TEST(NGConstraintSpaceTest, LayoutOpportunitiesTwoInMiddleWithOriginAndLeader) { 212 TEST(NGConstraintSpaceTest, LayoutOpportunitiesTwoInMiddleWithOrigin) {
213 NGPhysicalSize physical_size; 213 NGPhysicalSize physical_size;
214 physical_size.width = LayoutUnit(600); 214 physical_size.width = LayoutUnit(600);
215 physical_size.height = LayoutUnit(400); 215 physical_size.height = LayoutUnit(400);
216 216
217 auto* space = 217 auto* space =
218 ConstructConstraintSpace(HorizontalTopBottom, LeftToRight, physical_size); 218 ConstructConstraintSpace(HorizontalTopBottom, LeftToRight, physical_size);
219 // Add exclusions 219 // Add exclusions
220 NGLogicalRect exclusion1; 220 NGLogicalRect exclusion1;
221 exclusion1.size = {/* inline_size */ LayoutUnit(100), 221 exclusion1.size = {/* inline_size */ LayoutUnit(100),
222 /* block_size */ LayoutUnit(100)}; 222 /* block_size */ LayoutUnit(100)};
223 exclusion1.offset = {/* inline_offset */ LayoutUnit(150), 223 exclusion1.offset = {/* inline_offset */ LayoutUnit(150),
224 /* block_offset */ LayoutUnit(200)}; 224 /* block_offset */ LayoutUnit(200)};
225 space->AddExclusion(exclusion1); 225 space->AddExclusion(exclusion1);
226 NGLogicalRect exclusion2; 226 NGLogicalRect exclusion2;
227 exclusion2.size = {/* inline_size */ LayoutUnit(50), 227 exclusion2.size = {/* inline_size */ LayoutUnit(50),
228 /* block_size */ LayoutUnit(50)}; 228 /* block_size */ LayoutUnit(50)};
229 exclusion2.offset = {/* inline_offset */ LayoutUnit(500), 229 exclusion2.offset = {/* inline_offset */ LayoutUnit(500),
230 /* block_offset */ LayoutUnit(350)}; 230 /* block_offset */ LayoutUnit(350)};
231 space->AddExclusion(exclusion2); 231 space->AddExclusion(exclusion2);
232 232
233 const NGLogicalOffset origin_point = {LayoutUnit(0), LayoutUnit(200)}; 233 const NGLogicalOffset origin_point = {LayoutUnit(0), LayoutUnit(200)};
234 const NGLogicalOffset leader_point = {LayoutUnit(250), LayoutUnit(300)}; 234 auto* iterator = new NGLayoutOpportunityIterator(space, origin_point);
235 auto* iterator =
236 new NGLayoutOpportunityIterator(space, origin_point, leader_point);
237 235
238 // 1st Start Point 236 // 1st Start Point
237 EXPECT_EQ("0,200 150x200", OpportunityToString(iterator->Next()));
238
239 // 2nd Start Point
239 EXPECT_EQ("250,200 350x150", OpportunityToString(iterator->Next())); 240 EXPECT_EQ("250,200 350x150", OpportunityToString(iterator->Next()));
240 EXPECT_EQ("250,200 250x200", OpportunityToString(iterator->Next())); 241 EXPECT_EQ("250,200 250x200", OpportunityToString(iterator->Next()));
241 242
242 // 2nd Start Point 243 // 3rd Start Point
243 EXPECT_EQ("550,200 50x200", OpportunityToString(iterator->Next())); 244 EXPECT_EQ("550,200 50x200", OpportunityToString(iterator->Next()));
244 245
245 // 3rd Start Point 246 // 4th Start Point
246 EXPECT_EQ("0,300 600x50", OpportunityToString(iterator->Next())); 247 EXPECT_EQ("0,300 600x50", OpportunityToString(iterator->Next()));
247 EXPECT_EQ("0,300 500x100", OpportunityToString(iterator->Next())); 248 EXPECT_EQ("0,300 500x100", OpportunityToString(iterator->Next()));
248 249
249 // Iterator is exhausted. 250 // Iterator is exhausted.
250 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next())); 251 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next()));
251 } 252 }
252 253
253 // Verifies that Layout Opportunity iterator ignores the exclusion that is not 254 // Verifies that Layout Opportunity iterator ignores the exclusion that is not
254 // within constraint space. 255 // within constraint space.
255 // 256 //
(...skipping 24 matching lines...) Expand all
280 space->AddExclusion(exclusion); 281 space->AddExclusion(exclusion);
281 282
282 auto* iterator = space->LayoutOpportunities(); 283 auto* iterator = space->LayoutOpportunities();
283 284
284 EXPECT_EQ("0,0 600x100", OpportunityToString(iterator->Next())); 285 EXPECT_EQ("0,0 600x100", OpportunityToString(iterator->Next()));
285 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next())); 286 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next()));
286 } 287 }
287 288
288 } // namespace 289 } // namespace
289 } // namespace blink 290 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ng/ng_layout_opportunity_iterator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698