| OLD | NEW |
| 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "ash/common/system/tray/tri_view.h" | 7 #include "ash/common/system/tray/tri_view.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/gfx/geometry/insets.h" | 10 #include "ui/gfx/geometry/insets.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 tri_view_->AddView(TriView::Container::CENTER, center_child); | 91 tri_view_->AddView(TriView::Container::CENTER, center_child); |
| 92 tri_view_->AddView(TriView::Container::END, end_child); | 92 tri_view_->AddView(TriView::Container::END, end_child); |
| 93 | 93 |
| 94 tri_view_->Layout(); | 94 tri_view_->Layout(); |
| 95 | 95 |
| 96 EXPECT_EQ(0, GetBoundsInHost(start_child).y()); | 96 EXPECT_EQ(0, GetBoundsInHost(start_child).y()); |
| 97 EXPECT_EQ(kViewWidth, GetBoundsInHost(center_child).y()); | 97 EXPECT_EQ(kViewWidth, GetBoundsInHost(center_child).y()); |
| 98 EXPECT_EQ(kViewWidth * 2, GetBoundsInHost(end_child).y()); | 98 EXPECT_EQ(kViewWidth * 2, GetBoundsInHost(end_child).y()); |
| 99 } | 99 } |
| 100 | 100 |
| 101 TEST_F(TriViewTest, MinCrossAxisSize) { | |
| 102 const int kMinCrossAxisSize = 15; | |
| 103 EXPECT_EQ(0, tri_view_->GetPreferredSize().height()); | |
| 104 tri_view_->SetMinCrossAxisSize(kMinCrossAxisSize); | |
| 105 EXPECT_EQ(kMinCrossAxisSize, tri_view_->GetPreferredSize().height()); | |
| 106 EXPECT_EQ(kMinCrossAxisSize, tri_view_->GetHeightForWidth(0)); | |
| 107 } | |
| 108 | |
| 109 TEST_F(TriViewTest, MainAxisMinSize) { | 101 TEST_F(TriViewTest, MainAxisMinSize) { |
| 110 tri_view_->SetBounds(0, 0, 100, 10); | 102 tri_view_->SetBounds(0, 0, 100, 10); |
| 111 const gfx::Size kMinSize(15, 10); | 103 const gfx::Size kMinSize(15, 10); |
| 112 tri_view_->SetMinSize(TriView::Container::START, kMinSize); | 104 tri_view_->SetMinSize(TriView::Container::START, kMinSize); |
| 113 views::View* child = new views::StaticSizedView(gfx::Size(10, 10)); | 105 views::View* child = new views::StaticSizedView(gfx::Size(10, 10)); |
| 114 tri_view_->AddView(TriView::Container::CENTER, child); | 106 tri_view_->AddView(TriView::Container::CENTER, child); |
| 115 | 107 |
| 116 tri_view_->Layout(); | 108 tri_view_->Layout(); |
| 117 | 109 |
| 118 EXPECT_EQ(kMinSize.width(), GetBoundsInHost(child).x()); | 110 EXPECT_EQ(kMinSize.width(), GetBoundsInHost(child).x()); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 tri_view_->SetMaxSize(TriView::Container::CENTER, kMaxCenterSize); | 314 tri_view_->SetMaxSize(TriView::Container::CENTER, kMaxCenterSize); |
| 323 tri_view_->Layout(); | 315 tri_view_->Layout(); |
| 324 | 316 |
| 325 EXPECT_EQ(kViewSize, GetBoundsInHost(start_child).size()); | 317 EXPECT_EQ(kViewSize, GetBoundsInHost(start_child).size()); |
| 326 EXPECT_EQ(kExpectedCenterSize, | 318 EXPECT_EQ(kExpectedCenterSize, |
| 327 GetBoundsInHost(GetContainer(TriView::Container::CENTER)).size()); | 319 GetBoundsInHost(GetContainer(TriView::Container::CENTER)).size()); |
| 328 EXPECT_EQ(kViewSize, GetBoundsInHost(end_child).size()); | 320 EXPECT_EQ(kViewSize, GetBoundsInHost(end_child).size()); |
| 329 } | 321 } |
| 330 | 322 |
| 331 } // namespace ash | 323 } // namespace ash |
| OLD | NEW |