| 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 #include <utility> |
| 6 | 7 |
| 7 #include "ash/system/tray/tri_view.h" | 8 #include "ash/system/tray/tri_view.h" |
| 8 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/gfx/geometry/insets.h" | 11 #include "ui/gfx/geometry/insets.h" |
| 11 #include "ui/gfx/geometry/rect_conversions.h" | 12 #include "ui/gfx/geometry/rect_conversions.h" |
| 12 #include "ui/views/layout/box_layout.h" | 13 #include "ui/views/layout/box_layout.h" |
| 13 #include "ui/views/test/test_layout_manager.h" | 14 #include "ui/views/test/test_layout_manager.h" |
| 14 #include "ui/views/test/test_views.h" | 15 #include "ui/views/test/test_views.h" |
| 15 #include "ui/views/view.h" | 16 #include "ui/views/view.h" |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 EXPECT_NE(kMinHeight, GetMinHeight(TriView::Container::CENTER)); | 371 EXPECT_NE(kMinHeight, GetMinHeight(TriView::Container::CENTER)); |
| 371 EXPECT_NE(kMinHeight, GetMinHeight(TriView::Container::END)); | 372 EXPECT_NE(kMinHeight, GetMinHeight(TriView::Container::END)); |
| 372 | 373 |
| 373 tri_view_->SetMinHeight(kMinHeight); | 374 tri_view_->SetMinHeight(kMinHeight); |
| 374 | 375 |
| 375 EXPECT_EQ(kMinHeight, GetMinHeight(TriView::Container::START)); | 376 EXPECT_EQ(kMinHeight, GetMinHeight(TriView::Container::START)); |
| 376 EXPECT_EQ(kMinHeight, GetMinHeight(TriView::Container::CENTER)); | 377 EXPECT_EQ(kMinHeight, GetMinHeight(TriView::Container::CENTER)); |
| 377 EXPECT_EQ(kMinHeight, GetMinHeight(TriView::Container::END)); | 378 EXPECT_EQ(kMinHeight, GetMinHeight(TriView::Container::END)); |
| 378 } | 379 } |
| 379 | 380 |
| 381 TEST_F(TriViewTest, ChangingContainersVisibilityPerformsLayout) { |
| 382 const int kViewWidth = 10; |
| 383 const int kViewHeight = 10; |
| 384 const gfx::Size kEndViewSize(kViewWidth, kViewHeight); |
| 385 |
| 386 tri_view_->SetBounds(0, 0, 3 * kViewWidth, kViewHeight); |
| 387 tri_view_->SetFlexForContainer(TriView::Container::CENTER, 1.f); |
| 388 |
| 389 views::View* start_child = new views::View(); |
| 390 start_child->SetPreferredSize(kEndViewSize); |
| 391 |
| 392 views::View* center_child = new views::View(); |
| 393 center_child->SetPreferredSize(gfx::Size(2 * kViewWidth, kViewHeight)); |
| 394 |
| 395 views::View* end_child = new views::View(); |
| 396 end_child->SetPreferredSize(kEndViewSize); |
| 397 |
| 398 tri_view_->AddView(TriView::Container::START, start_child); |
| 399 tri_view_->AddView(TriView::Container::CENTER, center_child); |
| 400 tri_view_->AddView(TriView::Container::END, end_child); |
| 401 |
| 402 tri_view_->Layout(); |
| 403 |
| 404 EXPECT_EQ(gfx::Size(kViewWidth, kViewHeight), center_child->size()); |
| 405 |
| 406 tri_view_->SetContainerVisible(TriView::Container::END, false); |
| 407 |
| 408 EXPECT_EQ(gfx::Size(2 * kViewWidth, kViewHeight), center_child->size()); |
| 409 } |
| 410 |
| 380 } // namespace ash | 411 } // namespace ash |
| OLD | NEW |