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/controls/scroll_view.h" | 5 #include "ui/views/controls/scroll_view.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "ui/views/controls/scrollbar/overlay_scroll_bar.h" | 8 #include "ui/views/controls/scrollbar/overlay_scroll_bar.h" |
9 #include "ui/views/test/test_views.h" | 9 #include "ui/views/test/test_views.h" |
10 | 10 |
11 namespace views { | 11 namespace views { |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 const int kWidth = 100; | 15 const int kWidth = 100; |
16 const int kMinHeight = 50; | 16 const int kMinHeight = 50; |
17 const int kMaxHeight = 100; | 17 const int kMaxHeight = 100; |
18 | 18 |
19 // View implementation that allows setting the preferred size. | 19 // View implementation that allows setting the preferred size. |
20 class CustomView : public View { | 20 class CustomView : public View { |
21 public: | 21 public: |
22 CustomView() {} | 22 CustomView() {} |
23 | 23 |
24 void SetPreferredSize(const gfx::Size& size) { | 24 void SetPreferredSize(const gfx::Size& size) { |
25 preferred_size_ = size; | 25 preferred_size_ = size; |
26 PreferredSizeChanged(); | 26 PreferredSizeChanged(); |
27 } | 27 } |
28 | 28 |
29 virtual gfx::Size GetPreferredSize() const OVERRIDE { | 29 virtual gfx::Size GetPreferredSize() const override { |
30 return preferred_size_; | 30 return preferred_size_; |
31 } | 31 } |
32 | 32 |
33 virtual void Layout() OVERRIDE { | 33 virtual void Layout() override { |
34 gfx::Size pref = GetPreferredSize(); | 34 gfx::Size pref = GetPreferredSize(); |
35 int width = pref.width(); | 35 int width = pref.width(); |
36 int height = pref.height(); | 36 int height = pref.height(); |
37 if (parent()) { | 37 if (parent()) { |
38 width = std::max(parent()->width(), width); | 38 width = std::max(parent()->width(), width); |
39 height = std::max(parent()->height(), height); | 39 height = std::max(parent()->height(), height); |
40 } | 40 } |
41 SetBounds(x(), y(), width, height); | 41 SetBounds(x(), y(), width, height); |
42 } | 42 } |
43 | 43 |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 EXPECT_FALSE(corner_view->parent()); | 369 EXPECT_FALSE(corner_view->parent()); |
370 | 370 |
371 // Corner view should reappear when both scrollbars reappear. | 371 // Corner view should reappear when both scrollbars reappear. |
372 contents->SetBounds(0, 0, 200, 200); | 372 contents->SetBounds(0, 0, 200, 200); |
373 scroll_view.Layout(); | 373 scroll_view.Layout(); |
374 EXPECT_EQ(&scroll_view, corner_view->parent()); | 374 EXPECT_EQ(&scroll_view, corner_view->parent()); |
375 EXPECT_TRUE(corner_view->visible()); | 375 EXPECT_TRUE(corner_view->visible()); |
376 } | 376 } |
377 | 377 |
378 } // namespace views | 378 } // namespace views |
OLD | NEW |