| 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_layout_constants.h" | 7 #include "ash/ash_layout_constants.h" |
| 8 #include "ash/frame/caption_buttons/frame_caption_button.h" | 8 #include "ash/frame/caption_buttons/frame_caption_button.h" |
| 9 #include "ash/resources/grit/ash_resources.h" | 9 #include "ash/resources/grit/ash_resources.h" |
| 10 #include "ash/resources/vector_icons/vector_icons.h" | 10 #include "ash/resources/vector_icons/vector_icons.h" |
| 11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
| 13 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 13 #include "ash/wm/tablet_mode/tablet_mode_controller.h" |
| 14 #include "ui/gfx/geometry/rect.h" | 14 #include "ui/gfx/geometry/rect.h" |
| 15 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
| 16 #include "ui/views/widget/widget_delegate.h" | 16 #include "ui/views/widget/widget_delegate.h" |
| 17 | 17 |
| 18 namespace ash { | 18 namespace ash { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 class TestWidgetDelegate : public views::WidgetDelegateView { | 22 class TestWidgetDelegate : public views::WidgetDelegateView { |
| 23 public: | 23 public: |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 gfx::Rect initial_close_button_bounds = test.close_button()->bounds(); | 158 gfx::Rect initial_close_button_bounds = test.close_button()->bounds(); |
| 159 gfx::Rect initial_container_bounds = container.bounds(); | 159 gfx::Rect initial_container_bounds = container.bounds(); |
| 160 | 160 |
| 161 ASSERT_EQ(initial_size_button_bounds.x(), | 161 ASSERT_EQ(initial_size_button_bounds.x(), |
| 162 initial_minimize_button_bounds.right()); | 162 initial_minimize_button_bounds.right()); |
| 163 ASSERT_EQ(initial_close_button_bounds.x(), | 163 ASSERT_EQ(initial_close_button_bounds.x(), |
| 164 initial_size_button_bounds.right()); | 164 initial_size_button_bounds.right()); |
| 165 | 165 |
| 166 // Hidden size button should result in minimize button animating to the | 166 // Hidden size button should result in minimize button animating to the |
| 167 // right. The size button should not be visible, but should not have moved. | 167 // right. The size button should not be visible, but should not have moved. |
| 168 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 168 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true); |
| 169 true); | |
| 170 container.UpdateSizeButtonVisibility(); | 169 container.UpdateSizeButtonVisibility(); |
| 171 test.EndAnimations(); | 170 test.EndAnimations(); |
| 172 // Parent needs to layout in response to size change. | 171 // Parent needs to layout in response to size change. |
| 173 container.Layout(); | 172 container.Layout(); |
| 174 | 173 |
| 175 EXPECT_TRUE(test.minimize_button()->visible()); | 174 EXPECT_TRUE(test.minimize_button()->visible()); |
| 176 EXPECT_FALSE(test.size_button()->visible()); | 175 EXPECT_FALSE(test.size_button()->visible()); |
| 177 EXPECT_TRUE(test.close_button()->visible()); | 176 EXPECT_TRUE(test.close_button()->visible()); |
| 178 gfx::Rect minimize_button_bounds = test.minimize_button()->bounds(); | 177 gfx::Rect minimize_button_bounds = test.minimize_button()->bounds(); |
| 179 gfx::Rect close_button_bounds = test.close_button()->bounds(); | 178 gfx::Rect close_button_bounds = test.close_button()->bounds(); |
| 180 EXPECT_EQ(close_button_bounds.x(), minimize_button_bounds.right()); | 179 EXPECT_EQ(close_button_bounds.x(), minimize_button_bounds.right()); |
| 181 EXPECT_EQ(initial_size_button_bounds, test.size_button()->bounds()); | 180 EXPECT_EQ(initial_size_button_bounds, test.size_button()->bounds()); |
| 182 EXPECT_EQ(initial_close_button_bounds.size(), close_button_bounds.size()); | 181 EXPECT_EQ(initial_close_button_bounds.size(), close_button_bounds.size()); |
| 183 EXPECT_LT(container.GetPreferredSize().width(), | 182 EXPECT_LT(container.GetPreferredSize().width(), |
| 184 initial_container_bounds.width()); | 183 initial_container_bounds.width()); |
| 185 | 184 |
| 186 // Revealing the size button should cause the minimize button to return to its | 185 // Revealing the size button should cause the minimize button to return to its |
| 187 // original position. | 186 // original position. |
| 188 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 187 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(false); |
| 189 false); | |
| 190 container.UpdateSizeButtonVisibility(); | 188 container.UpdateSizeButtonVisibility(); |
| 191 // Calling code needs to layout in response to size change. | 189 // Calling code needs to layout in response to size change. |
| 192 container.Layout(); | 190 container.Layout(); |
| 193 test.EndAnimations(); | 191 test.EndAnimations(); |
| 194 EXPECT_TRUE(test.minimize_button()->visible()); | 192 EXPECT_TRUE(test.minimize_button()->visible()); |
| 195 EXPECT_TRUE(test.size_button()->visible()); | 193 EXPECT_TRUE(test.size_button()->visible()); |
| 196 EXPECT_TRUE(test.close_button()->visible()); | 194 EXPECT_TRUE(test.close_button()->visible()); |
| 197 EXPECT_EQ(initial_minimize_button_bounds, test.minimize_button()->bounds()); | 195 EXPECT_EQ(initial_minimize_button_bounds, test.minimize_button()->bounds()); |
| 198 EXPECT_EQ(initial_size_button_bounds, test.size_button()->bounds()); | 196 EXPECT_EQ(initial_size_button_bounds, test.size_button()->bounds()); |
| 199 EXPECT_EQ(initial_close_button_bounds, test.close_button()->bounds()); | 197 EXPECT_EQ(initial_close_button_bounds, test.close_button()->bounds()); |
| 200 EXPECT_EQ(container.GetPreferredSize().width(), | 198 EXPECT_EQ(container.GetPreferredSize().width(), |
| 201 initial_container_bounds.width()); | 199 initial_container_bounds.width()); |
| 202 } | 200 } |
| 203 | 201 |
| 204 } // namespace ash | 202 } // namespace ash |
| OLD | NEW |