| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/views/test/test_views.h" | 10 #include "ui/views/test/test_views.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 host_->Layout(); | 148 host_->Layout(); |
| 149 EXPECT_EQ(gfx::Rect(10, 10, 10, 10), v2->bounds()); | 149 EXPECT_EQ(gfx::Rect(10, 10, 10, 10), v2->bounds()); |
| 150 } | 150 } |
| 151 | 151 |
| 152 TEST_F(BoxLayoutTest, UseHeightForWidth) { | 152 TEST_F(BoxLayoutTest, UseHeightForWidth) { |
| 153 BoxLayout* layout = new BoxLayout(BoxLayout::kVertical, 0, 0, 0); | 153 BoxLayout* layout = new BoxLayout(BoxLayout::kVertical, 0, 0, 0); |
| 154 host_->SetLayoutManager(layout); | 154 host_->SetLayoutManager(layout); |
| 155 View* v1 = new StaticSizedView(gfx::Size(20, 10)); | 155 View* v1 = new StaticSizedView(gfx::Size(20, 10)); |
| 156 host_->AddChildView(v1); | 156 host_->AddChildView(v1); |
| 157 ProportionallySizedView* v2 = new ProportionallySizedView(2); | 157 ProportionallySizedView* v2 = new ProportionallySizedView(2); |
| 158 v2->set_preferred_width(10); | 158 v2->SetPreferredWidth(10); |
| 159 host_->AddChildView(v2); | 159 host_->AddChildView(v2); |
| 160 EXPECT_EQ(gfx::Size(20, 50), layout->GetPreferredSize(host_.get())); | 160 EXPECT_EQ(gfx::Size(20, 50), layout->GetPreferredSize(host_.get())); |
| 161 | 161 |
| 162 host_->SetBounds(0, 0, 20, 50); | 162 host_->SetBounds(0, 0, 20, 50); |
| 163 host_->Layout(); | 163 host_->Layout(); |
| 164 EXPECT_EQ(gfx::Rect(0, 0, 20, 10), v1->bounds()); | 164 EXPECT_EQ(gfx::Rect(0, 0, 20, 10), v1->bounds()); |
| 165 EXPECT_EQ(gfx::Rect(0, 10, 20, 40), v2->bounds()); | 165 EXPECT_EQ(gfx::Rect(0, 10, 20, 40), v2->bounds()); |
| 166 | 166 |
| 167 EXPECT_EQ(110, layout->GetPreferredHeightForWidth(host_.get(), 50)); | 167 EXPECT_EQ(110, layout->GetPreferredHeightForWidth(host_.get(), 50)); |
| 168 | 168 |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 BoxLayout* layout = new BoxLayout(BoxLayout::kHorizontal, 0, 0, 0); | 623 BoxLayout* layout = new BoxLayout(BoxLayout::kHorizontal, 0, 0, 0); |
| 624 host_->SetLayoutManager(layout); | 624 host_->SetLayoutManager(layout); |
| 625 View* v1 = new StaticSizedView(gfx::Size(20, 10)); | 625 View* v1 = new StaticSizedView(gfx::Size(20, 10)); |
| 626 host_->AddChildView(v1); | 626 host_->AddChildView(v1); |
| 627 layout->set_minimum_cross_axis_size(30); | 627 layout->set_minimum_cross_axis_size(30); |
| 628 | 628 |
| 629 EXPECT_EQ(gfx::Size(20, 30), layout->GetPreferredSize(host_.get())); | 629 EXPECT_EQ(gfx::Size(20, 30), layout->GetPreferredSize(host_.get())); |
| 630 } | 630 } |
| 631 | 631 |
| 632 } // namespace views | 632 } // namespace views |
| OLD | NEW |