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

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

Issue 2451123003: Make NGLayoutOpportunityIterator to support origin_point. (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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/ng/ng_constraint_space_test.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_constraint_space_test.cc b/third_party/WebKit/Source/core/layout/ng/ng_constraint_space_test.cc
index a43f46e402149359aa6448e1b123b0f950564d80..2b12d480cddd2e10e6386d64613f5bf053e0c9c4 100644
--- a/third_party/WebKit/Source/core/layout/ng/ng_constraint_space_test.cc
+++ b/third_party/WebKit/Source/core/layout/ng/ng_constraint_space_test.cc
@@ -117,16 +117,16 @@ TEST(NGConstraintSpaceTest, LayoutOpportunitiesTopLeftExclusion) {
//
// Test case visual representation:
//
-// 100 200 300 400 500
-// (1)--|----|----|-(2)|----|-(3)+
-// 50 | |
-// 100 | |
-// 150 | |
-// 200 | ********** |
-// 250 | ********** |
-// 300 (4) |
-// 350 | *** |
-// +-----------------------------+
+// 100 200 300 400 500
+// (1)--|----|-(2)-|----|----|-(3)-+
+// 50 | |
+// 100 | |
+// 150 | |
+// 200 | ****** |
+// 250 | ****** |
+// 300 (4) |
+// 350 | *** |
+// +-------------------------------+
//
// Expected:
// Layout opportunity iterator generates the next opportunities:
@@ -169,6 +169,54 @@ TEST(NGConstraintSpaceTest, LayoutOpportunitiesTwoInMiddle) {
EXPECT_EQ("(empty)", OpportunityToString(iterator->Next()));
}
+// This test is the same as LayoutOpportunitiesTwoInMiddle with the only
+// difference that NGLayoutOpportunityIterator takes the additional argument
+// origin_point that changes the iterator to return Layout Opportunities that
+// lay after the origin point.
+//
+// Expected:
+// Layout opportunity iterator generates the next opportunities:
+// - 1st Start Point (0, 200): 150x200
+// - 2nd Start Point (250, 200): 350x150, 250x200
+// - 3rd Start Point (550, 200): 50x200
+// - 4th Start Point (0, 300): 600x50, 500x100
+// All other opportunities that are located before the origin point should be
+// filtered out.
+TEST(NGConstraintSpaceTest, LayoutOpportunitiesTwoInMiddleWithOrigin) {
ikilpatrick 2016/10/28 16:39:28 \o/
+ NGPhysicalSize physical_size;
+ physical_size.width = LayoutUnit(600);
+ physical_size.height = LayoutUnit(400);
+ auto* physical_space = new NGPhysicalConstraintSpace(physical_size);
+
+ // Add exclusions
+ physical_space->AddExclusion(new NGExclusion(
+ LayoutUnit(200), LayoutUnit(250), LayoutUnit(300), LayoutUnit(150)));
+ physical_space->AddExclusion(new NGExclusion(
+ LayoutUnit(350), LayoutUnit(550), LayoutUnit(400), LayoutUnit(500)));
+
+ auto* space =
+ new NGConstraintSpace(HorizontalTopBottom, LeftToRight, physical_space);
+ const NGLogicalOffset origin_point = {LayoutUnit(0), LayoutUnit(200)};
+ auto* iterator = new NGLayoutOpportunityIterator(space, origin_point);
+
+ // 1st Start Point
+ EXPECT_EQ("0,200 150x200", OpportunityToString(iterator->Next()));
+
+ // 2nd Start Point
+ EXPECT_EQ("250,200 350x150", OpportunityToString(iterator->Next()));
+ EXPECT_EQ("250,200 250x200", OpportunityToString(iterator->Next()));
+
+ // 3rd Start Point
+ EXPECT_EQ("550,200 50x200", OpportunityToString(iterator->Next()));
+
+ // 4th Start Point
+ EXPECT_EQ("0,300 600x50", OpportunityToString(iterator->Next()));
+ EXPECT_EQ("0,300 500x100", OpportunityToString(iterator->Next()));
+
+ // Iterator is exhausted.
+ EXPECT_EQ("(empty)", OpportunityToString(iterator->Next()));
+}
+
// Verifies that Layout Opportunity iterator ignores the exclusion that is not
// within constraint space.
//
« 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