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

Unified Diff: ui/views/layout/grid_layout_unittest.cc

Issue 2625083003: Implement Harmony-style consistent button widths for Collected Cookies. (Closed)
Patch Set: selfnits Created 3 years, 9 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
« ui/views/layout/grid_layout.cc ('K') | « ui/views/layout/grid_layout.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/layout/grid_layout_unittest.cc
diff --git a/ui/views/layout/grid_layout_unittest.cc b/ui/views/layout/grid_layout_unittest.cc
index 6db72f6f857ec1f6f4db18f80114d908ea2e4781..f6776d6b36fde12b868d99ebd42b54d263bec3c1 100644
--- a/ui/views/layout/grid_layout_unittest.cc
+++ b/ui/views/layout/grid_layout_unittest.cc
@@ -26,8 +26,10 @@ class SettableSizeView : public View {
gfx::Size GetPreferredSize() const override { return pref_; }
+ void set_pref(const gfx::Size& pref) { pref_ = pref; }
+
private:
- gfx::Size pref_;
+ gfx::Size pref_;
Peter Kasting 2017/03/07 02:50:37 Nit: While here: DISALLOW_COPY_AND_ASSIGN
tapted 2017/03/07 12:06:41 Done.
};
// A view with fixed circumference that trades height for width.
@@ -144,6 +146,65 @@ TEST_F(GridLayoutTest, TwoColumns) {
RemoveAll();
}
+// Test linked column sizes, and the column size limit.
+TEST_F(GridLayoutTest, TwoColumnsLinkedSizes) {
+ SettableSizeView v1(gfx::Size(10, 20));
+ SettableSizeView v2(gfx::Size(20, 20));
+ ColumnSet* c1 = layout.AddColumnSet(0);
+
+ // Fill widths.
+ c1->AddColumn(GridLayout::FILL, GridLayout::LEADING, 0, GridLayout::USE_PREF,
+ 0, 0);
+ c1->AddColumn(GridLayout::FILL, GridLayout::LEADING, 0, GridLayout::USE_PREF,
+ 0, 0);
+
+ layout.StartRow(0, 0);
+ layout.AddView(&v1);
+ layout.AddView(&v2);
+
+ c1->LinkColumnSizes(0, 1, -1);
+ GetPreferredSize();
+
+ // |v1| should obtain the same width as |v2|, since |v2| is larger.
+ EXPECT_EQ(gfx::Size(20 + 20, 20), pref);
+ host.SetBounds(0, 0, pref.width(), pref.height());
+ layout.Layout(&host);
+ ExpectViewBoundsEquals(0, 0, 20, 20, &v1);
+ ExpectViewBoundsEquals(20, 0, 20, 20, &v2);
+
+ // If the limit is zero, behaves as though the columns are not linked.
+ c1->set_linked_column_size_limit(0);
+ GetPreferredSize();
+ EXPECT_EQ(gfx::Size(10 + 20, 20), pref);
+ host.SetBounds(0, 0, pref.width(), pref.height());
+ layout.Layout(&host);
+ ExpectViewBoundsEquals(0, 0, 10, 20, &v1);
+ ExpectViewBoundsEquals(10, 0, 20, 20, &v2);
+
+ // Set a size limit.
+ c1->set_linked_column_size_limit(40);
+ v1.set_pref(gfx::Size(35, 20));
+ GetPreferredSize();
+
+ // |v1| now dominates, but it is still below the limit.
+ EXPECT_EQ(gfx::Size(35 + 35, 20), pref);
+ host.SetBounds(0, 0, pref.width(), pref.height());
+ layout.Layout(&host);
+ ExpectViewBoundsEquals(0, 0, 35, 20, &v1);
+ ExpectViewBoundsEquals(35, 0, 35, 20, &v2);
+
+ // Go over the limit. There should be no influence on the size of |v2| at all.
+ v1.set_pref(gfx::Size(45, 20));
+ GetPreferredSize();
+ EXPECT_EQ(gfx::Size(45 + 20, 20), pref);
+ host.SetBounds(0, 0, pref.width(), pref.height());
+ layout.Layout(&host);
+ ExpectViewBoundsEquals(0, 0, 45, 20, &v1);
+ ExpectViewBoundsEquals(45, 0, 20, 20, &v2);
+
Peter Kasting 2017/03/07 02:50:37 Should there be a test case that if you have 3 lin
tapted 2017/03/07 12:06:41 Done.
+ RemoveAll();
+}
+
TEST_F(GridLayoutTest, ColSpan1) {
SettableSizeView v1(gfx::Size(100, 20));
SettableSizeView v2(gfx::Size(10, 40));
« ui/views/layout/grid_layout.cc ('K') | « ui/views/layout/grid_layout.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698