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

Side by Side Diff: ui/views/layout/box_layout_unittest.cc

Issue 1422703004: BoxLayout: Added set_collapse_when_hidden(), like views::Label. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@exclusiveaccess-minor-refactor
Patch Set: Created 5 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
« ui/views/layout/box_layout.cc ('K') | « ui/views/layout/box_layout.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/layout/box_layout.h" 5 #include "ui/views/layout/box_layout.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/views/test/test_views.h" 8 #include "ui/views/test/test_views.h"
9 #include "ui/views/view.h" 9 #include "ui/views/view.h"
10 10
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 TEST_F(BoxLayoutTest, NoSpace) { 126 TEST_F(BoxLayoutTest, NoSpace) {
127 BoxLayout* layout = new BoxLayout(BoxLayout::kHorizontal, 10, 10, 10); 127 BoxLayout* layout = new BoxLayout(BoxLayout::kHorizontal, 10, 10, 10);
128 host_->SetLayoutManager(layout); 128 host_->SetLayoutManager(layout);
129 View* childView = new StaticSizedView(gfx::Size(20, 20)); 129 View* childView = new StaticSizedView(gfx::Size(20, 20));
130 host_->AddChildView(childView); 130 host_->AddChildView(childView);
131 host_->SetBounds(0, 0, 10, 10); 131 host_->SetBounds(0, 0, 10, 10);
132 host_->Layout(); 132 host_->Layout();
133 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), childView->bounds()); 133 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), childView->bounds());
134 } 134 }
135 135
136 TEST_F(BoxLayoutTest, InvisibleHost) {
137 BoxLayout* layout = new BoxLayout(BoxLayout::kHorizontal, 10, 10, 20);
138 host_->SetLayoutManager(layout);
139 host_->SetVisible(false);
140 // No collapse_when_hidden; expect full size.
141 EXPECT_EQ(gfx::Size(20, 20), layout->GetPreferredSize(host_.get()));
142
143 // Set collapse_when_hidden; expect 0x0.
144 layout->set_collapse_when_hidden(true);
145 EXPECT_EQ(gfx::Size(), layout->GetPreferredSize(host_.get()));
146 }
147
136 TEST_F(BoxLayoutTest, InvisibleChild) { 148 TEST_F(BoxLayoutTest, InvisibleChild) {
137 BoxLayout* layout = new BoxLayout(BoxLayout::kHorizontal, 10, 10, 10); 149 BoxLayout* layout = new BoxLayout(BoxLayout::kHorizontal, 10, 10, 10);
138 host_->SetLayoutManager(layout); 150 host_->SetLayoutManager(layout);
139 View* v1 = new StaticSizedView(gfx::Size(20, 20)); 151 View* v1 = new StaticSizedView(gfx::Size(20, 20));
140 v1->SetVisible(false); 152 v1->SetVisible(false);
141 host_->AddChildView(v1); 153 host_->AddChildView(v1);
142 View* v2 = new StaticSizedView(gfx::Size(10, 10)); 154 View* v2 = new StaticSizedView(gfx::Size(10, 10));
143 host_->AddChildView(v2); 155 host_->AddChildView(v2);
144 EXPECT_EQ(gfx::Size(30, 30), layout->GetPreferredSize(host_.get())); 156 EXPECT_EQ(gfx::Size(30, 30), layout->GetPreferredSize(host_.get()));
145 host_->SetBounds(0, 0, 30, 30); 157 host_->SetBounds(0, 0, 30, 30);
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 BoxLayout* layout = new BoxLayout(BoxLayout::kHorizontal, 0, 0, 0); 633 BoxLayout* layout = new BoxLayout(BoxLayout::kHorizontal, 0, 0, 0);
622 host_->SetLayoutManager(layout); 634 host_->SetLayoutManager(layout);
623 View* v1 = new StaticSizedView(gfx::Size(20, 10)); 635 View* v1 = new StaticSizedView(gfx::Size(20, 10));
624 host_->AddChildView(v1); 636 host_->AddChildView(v1);
625 layout->set_minimum_cross_axis_size(30); 637 layout->set_minimum_cross_axis_size(30);
626 638
627 EXPECT_EQ(gfx::Size(20, 30), layout->GetPreferredSize(host_.get())); 639 EXPECT_EQ(gfx::Size(20, 30), layout->GetPreferredSize(host_.get()));
628 } 640 }
629 641
630 } // namespace views 642 } // namespace views
OLDNEW
« ui/views/layout/box_layout.cc ('K') | « ui/views/layout/box_layout.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698