OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/window/custom_frame_view.h" | 5 #include "ui/views/window/custom_frame_view.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ui/views/controls/button/image_button.h" | 9 #include "ui/views/controls/button/image_button.h" |
10 #include "ui/views/test/views_test_base.h" | 10 #include "ui/views/test/views_test_base.h" |
11 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
12 #include "ui/views/widget/widget_delegate.h" | 12 #include "ui/views/widget/widget_delegate.h" |
13 #include "ui/views/window/window_button_order_provider.h" | 13 #include "ui/views/window/window_button_order_provider.h" |
14 | 14 |
15 namespace views { | 15 namespace views { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 // Allows for the control of whether or not the widget can minimize/maximize or | 19 // Allows for the control of whether or not the widget can minimize/maximize or |
20 // not. This can be set after initial setup in order to allow testing of both | 20 // not. This can be set after initial setup in order to allow testing of both |
21 // forms of delegates. By default this can minimize and maximize. | 21 // forms of delegates. By default this can minimize and maximize. |
22 class MinimizeAndMaximizeStateControlDelegate : public WidgetDelegateView { | 22 class MinimizeAndMaximizeStateControlDelegate : public WidgetDelegateView { |
23 public: | 23 public: |
24 MinimizeAndMaximizeStateControlDelegate() | 24 MinimizeAndMaximizeStateControlDelegate() |
25 : can_maximize_(true), | 25 : can_maximize_(true), |
26 can_minimize_(true) {} | 26 can_minimize_(true) {} |
27 virtual ~MinimizeAndMaximizeStateControlDelegate() {} | 27 ~MinimizeAndMaximizeStateControlDelegate() override {} |
28 | 28 |
29 void set_can_maximize(bool can_maximize) { | 29 void set_can_maximize(bool can_maximize) { |
30 can_maximize_ = can_maximize; | 30 can_maximize_ = can_maximize; |
31 } | 31 } |
32 | 32 |
33 void set_can_minimize(bool can_minimize) { | 33 void set_can_minimize(bool can_minimize) { |
34 can_minimize_ = can_minimize; | 34 can_minimize_ = can_minimize; |
35 } | 35 } |
36 | 36 |
37 // WidgetDelegate: | 37 // WidgetDelegate: |
38 virtual bool CanMaximize() const override { return can_maximize_; } | 38 bool CanMaximize() const override { return can_maximize_; } |
39 virtual bool CanMinimize() const override { return can_minimize_; } | 39 bool CanMinimize() const override { return can_minimize_; } |
40 | 40 |
41 private: | 41 private: |
42 bool can_maximize_; | 42 bool can_maximize_; |
43 bool can_minimize_; | 43 bool can_minimize_; |
44 | 44 |
45 DISALLOW_COPY_AND_ASSIGN(MinimizeAndMaximizeStateControlDelegate); | 45 DISALLOW_COPY_AND_ASSIGN(MinimizeAndMaximizeStateControlDelegate); |
46 }; | 46 }; |
47 | 47 |
48 } // namespace | 48 } // namespace |
49 | 49 |
50 class CustomFrameViewTest : public ViewsTestBase { | 50 class CustomFrameViewTest : public ViewsTestBase { |
51 public: | 51 public: |
52 CustomFrameViewTest() {} | 52 CustomFrameViewTest() {} |
53 virtual ~CustomFrameViewTest() {} | 53 ~CustomFrameViewTest() override {} |
54 | 54 |
55 CustomFrameView* custom_frame_view() { | 55 CustomFrameView* custom_frame_view() { |
56 return custom_frame_view_; | 56 return custom_frame_view_; |
57 } | 57 } |
58 | 58 |
59 MinimizeAndMaximizeStateControlDelegate* | 59 MinimizeAndMaximizeStateControlDelegate* |
60 minimize_and_maximize_state_control_delegate() { | 60 minimize_and_maximize_state_control_delegate() { |
61 return minimize_and_maximize_state_control_delegate_; | 61 return minimize_and_maximize_state_control_delegate_; |
62 } | 62 } |
63 | 63 |
64 Widget* widget() { | 64 Widget* widget() { |
65 return widget_; | 65 return widget_; |
66 } | 66 } |
67 | 67 |
68 // ViewsTestBase: | 68 // ViewsTestBase: |
69 virtual void SetUp() override; | 69 void SetUp() override; |
70 virtual void TearDown() override; | 70 void TearDown() override; |
71 | 71 |
72 protected: | 72 protected: |
73 const std::vector<views::FrameButton>& leading_buttons() { | 73 const std::vector<views::FrameButton>& leading_buttons() { |
74 return WindowButtonOrderProvider::GetInstance()->leading_buttons(); | 74 return WindowButtonOrderProvider::GetInstance()->leading_buttons(); |
75 } | 75 } |
76 | 76 |
77 const std::vector<views::FrameButton>& trailing_buttons() { | 77 const std::vector<views::FrameButton>& trailing_buttons() { |
78 return WindowButtonOrderProvider::GetInstance()->trailing_buttons(); | 78 return WindowButtonOrderProvider::GetInstance()->trailing_buttons(); |
79 } | 79 } |
80 | 80 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 parent->Maximize(); | 271 parent->Maximize(); |
272 view->Layout(); | 272 view->Layout(); |
273 | 273 |
274 EXPECT_GT(close_button()->bounds().width(), | 274 EXPECT_GT(close_button()->bounds().width(), |
275 close_button_initial_bounds.width()); | 275 close_button_initial_bounds.width()); |
276 EXPECT_GT(minimize_button()->bounds().width(), | 276 EXPECT_GT(minimize_button()->bounds().width(), |
277 minimize_button_initial_bounds.width()); | 277 minimize_button_initial_bounds.width()); |
278 } | 278 } |
279 | 279 |
280 } // namespace views | 280 } // namespace views |
OLD | NEW |