| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ash/frame/caption_buttons/frame_caption_button_container_view.h" | 5 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/frame/caption_buttons/frame_caption_button.h" | 8 #include "ash/frame/caption_buttons/frame_caption_button.h" |
| 9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 123 |
| 124 // Test how the allowed actions affect which caption buttons are visible. | 124 // Test how the allowed actions affect which caption buttons are visible. |
| 125 TEST_F(FrameCaptionButtonContainerViewTestOldStyle, ButtonVisibility) { | 125 TEST_F(FrameCaptionButtonContainerViewTestOldStyle, ButtonVisibility) { |
| 126 // The minimize button should be hidden when both minimizing and maximizing | 126 // The minimize button should be hidden when both minimizing and maximizing |
| 127 // are allowed because the size button can do both. | 127 // are allowed because the size button can do both. |
| 128 scoped_ptr<views::Widget> widget_can_maximize( | 128 scoped_ptr<views::Widget> widget_can_maximize( |
| 129 CreateTestWidget(MAXIMIZE_ALLOWED)); | 129 CreateTestWidget(MAXIMIZE_ALLOWED)); |
| 130 FrameCaptionButtonContainerView container1(widget_can_maximize.get(), | 130 FrameCaptionButtonContainerView container1(widget_can_maximize.get(), |
| 131 FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); | 131 FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); |
| 132 SetMockImages(&container1); | 132 SetMockImages(&container1); |
| 133 container1.SetBoundsRect(gfx::Rect(container1.GetPreferredSize())); |
| 133 container1.Layout(); | 134 container1.Layout(); |
| 134 FrameCaptionButtonContainerView::TestApi t1(&container1); | 135 FrameCaptionButtonContainerView::TestApi t1(&container1); |
| 135 EXPECT_FALSE(t1.minimize_button()->visible()); | 136 EXPECT_FALSE(t1.minimize_button()->visible()); |
| 136 EXPECT_TRUE(t1.size_button()->visible()); | 137 EXPECT_TRUE(t1.size_button()->visible()); |
| 137 EXPECT_TRUE(t1.close_button()->visible()); | 138 EXPECT_TRUE(t1.close_button()->visible()); |
| 138 EXPECT_TRUE(CheckButtonsAtEdges( | 139 EXPECT_TRUE(CheckButtonsAtEdges( |
| 139 &container1, *t1.size_button(), *t1.close_button())); | 140 &container1, *t1.size_button(), *t1.close_button())); |
| 140 | 141 |
| 141 // The minimize button should be visible when minimizing is allowed but | 142 // The minimize button should be visible when minimizing is allowed but |
| 142 // maximizing is disallowed. | 143 // maximizing is disallowed. |
| 143 scoped_ptr<views::Widget> widget_cannot_maximize( | 144 scoped_ptr<views::Widget> widget_cannot_maximize( |
| 144 CreateTestWidget(MAXIMIZE_DISALLOWED)); | 145 CreateTestWidget(MAXIMIZE_DISALLOWED)); |
| 145 FrameCaptionButtonContainerView container2(widget_cannot_maximize.get(), | 146 FrameCaptionButtonContainerView container2(widget_cannot_maximize.get(), |
| 146 FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); | 147 FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); |
| 147 SetMockImages(&container2); | 148 SetMockImages(&container2); |
| 149 container2.SetBoundsRect(gfx::Rect(container2.GetPreferredSize())); |
| 148 container2.Layout(); | 150 container2.Layout(); |
| 149 FrameCaptionButtonContainerView::TestApi t2(&container2); | 151 FrameCaptionButtonContainerView::TestApi t2(&container2); |
| 150 EXPECT_TRUE(t2.minimize_button()->visible()); | 152 EXPECT_TRUE(t2.minimize_button()->visible()); |
| 151 EXPECT_FALSE(t2.size_button()->visible()); | 153 EXPECT_FALSE(t2.size_button()->visible()); |
| 152 EXPECT_TRUE(t2.close_button()->visible()); | 154 EXPECT_TRUE(t2.close_button()->visible()); |
| 153 EXPECT_TRUE(CheckButtonsAtEdges( | 155 EXPECT_TRUE(CheckButtonsAtEdges( |
| 154 &container2, *t2.minimize_button(), *t2.close_button())); | 156 &container2, *t2.minimize_button(), *t2.close_button())); |
| 155 | 157 |
| 156 // Neither the minimize button nor the size button should be visible when | 158 // Neither the minimize button nor the size button should be visible when |
| 157 // neither minimizing nor maximizing are allowed. | 159 // neither minimizing nor maximizing are allowed. |
| 158 FrameCaptionButtonContainerView container3(widget_cannot_maximize.get(), | 160 FrameCaptionButtonContainerView container3(widget_cannot_maximize.get(), |
| 159 FrameCaptionButtonContainerView::MINIMIZE_DISALLOWED); | 161 FrameCaptionButtonContainerView::MINIMIZE_DISALLOWED); |
| 160 SetMockImages(&container3); | 162 SetMockImages(&container3); |
| 163 container3.SetBoundsRect(gfx::Rect(container3.GetPreferredSize())); |
| 161 container3.Layout(); | 164 container3.Layout(); |
| 162 FrameCaptionButtonContainerView::TestApi t3(&container3); | 165 FrameCaptionButtonContainerView::TestApi t3(&container3); |
| 163 EXPECT_FALSE(t3.minimize_button()->visible()); | 166 EXPECT_FALSE(t3.minimize_button()->visible()); |
| 164 EXPECT_FALSE(t3.size_button()->visible()); | 167 EXPECT_FALSE(t3.size_button()->visible()); |
| 165 EXPECT_TRUE(t3.close_button()->visible()); | 168 EXPECT_TRUE(t3.close_button()->visible()); |
| 166 EXPECT_TRUE(CheckButtonsAtEdges( | 169 EXPECT_TRUE(CheckButtonsAtEdges( |
| 167 &container3, *t3.close_button(), *t3.close_button())); | 170 &container3, *t3.close_button(), *t3.close_button())); |
| 168 } | 171 } |
| 169 | 172 |
| 170 class FrameCaptionButtonContainerViewTestAlternateStyle | 173 class FrameCaptionButtonContainerViewTestAlternateStyle |
| (...skipping 19 matching lines...) Expand all Loading... |
| 190 // default case. | 193 // default case. |
| 191 TEST_F(FrameCaptionButtonContainerViewTestAlternateStyle, ButtonVisibility) { | 194 TEST_F(FrameCaptionButtonContainerViewTestAlternateStyle, ButtonVisibility) { |
| 192 // Both the minimize button and the maximize button should be visible when | 195 // Both the minimize button and the maximize button should be visible when |
| 193 // both minimizing and maximizing are allowed when using the alternate | 196 // both minimizing and maximizing are allowed when using the alternate |
| 194 // button style. | 197 // button style. |
| 195 scoped_ptr<views::Widget> widget_can_maximize( | 198 scoped_ptr<views::Widget> widget_can_maximize( |
| 196 CreateTestWidget(MAXIMIZE_ALLOWED)); | 199 CreateTestWidget(MAXIMIZE_ALLOWED)); |
| 197 FrameCaptionButtonContainerView container(widget_can_maximize.get(), | 200 FrameCaptionButtonContainerView container(widget_can_maximize.get(), |
| 198 FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); | 201 FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); |
| 199 SetMockImages(&container); | 202 SetMockImages(&container); |
| 203 container.SetBoundsRect(gfx::Rect(container.GetPreferredSize())); |
| 200 container.Layout(); | 204 container.Layout(); |
| 201 FrameCaptionButtonContainerView::TestApi t(&container); | 205 FrameCaptionButtonContainerView::TestApi t(&container); |
| 202 EXPECT_TRUE(t.minimize_button()->visible()); | 206 EXPECT_TRUE(t.minimize_button()->visible()); |
| 203 EXPECT_TRUE(t.size_button()->visible()); | 207 EXPECT_TRUE(t.size_button()->visible()); |
| 204 EXPECT_TRUE(t.close_button()->visible()); | 208 EXPECT_TRUE(t.close_button()->visible()); |
| 205 EXPECT_TRUE(CheckButtonsAtEdges( | 209 EXPECT_TRUE(CheckButtonsAtEdges( |
| 206 &container, *t.minimize_button(), *t.close_button())); | 210 &container, *t.minimize_button(), *t.close_button())); |
| 207 } | 211 } |
| 208 | 212 |
| 209 } // namespace ash | 213 } // namespace ash |
| OLD | NEW |