| 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 "ash/wm/base_layout_manager.h" | 5 #include "ash/wm/base_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/screen_ash.h" | 7 #include "ash/screen_ash.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
| 10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "ui/aura/client/aura_constants.h" | 13 #include "ui/aura/client/aura_constants.h" |
| 14 #include "ui/aura/root_window.h" | 14 #include "ui/aura/root_window.h" |
| 15 #include "ui/aura/test/test_windows.h" | 15 #include "ui/aura/test/test_windows.h" |
| 16 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 17 #include "ui/base/ui_base_types.h" | 17 #include "ui/base/ui_base_types.h" |
| 18 #include "ui/gfx/insets.h" | 18 #include "ui/gfx/insets.h" |
| 19 #include "ui/gfx/monitor.h" |
| 19 | 20 |
| 20 namespace ash { | 21 namespace ash { |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 class BaseLayoutManagerTest : public test::AshTestBase { | 25 class BaseLayoutManagerTest : public test::AshTestBase { |
| 25 public: | 26 public: |
| 26 BaseLayoutManagerTest() {} | 27 BaseLayoutManagerTest() {} |
| 27 virtual ~BaseLayoutManagerTest() {} | 28 virtual ~BaseLayoutManagerTest() {} |
| 28 | 29 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 gfx::Rect old_bounds = window->bounds(); | 146 gfx::Rect old_bounds = window->bounds(); |
| 146 Shell::GetRootWindow()->SetHostSize(gfx::Size(800, 600)); | 147 Shell::GetRootWindow()->SetHostSize(gfx::Size(800, 600)); |
| 147 EXPECT_EQ(old_bounds.width(), window->bounds().width()); | 148 EXPECT_EQ(old_bounds.width(), window->bounds().width()); |
| 148 EXPECT_EQ(old_bounds.height(), window->bounds().height()); | 149 EXPECT_EQ(old_bounds.height(), window->bounds().height()); |
| 149 } | 150 } |
| 150 | 151 |
| 151 // Tests that a maximized window with too-large restore bounds will be restored | 152 // Tests that a maximized window with too-large restore bounds will be restored |
| 152 // to smaller than the full work area. | 153 // to smaller than the full work area. |
| 153 TEST_F(BaseLayoutManagerTest, BoundsWithScreenEdgeVisible) { | 154 TEST_F(BaseLayoutManagerTest, BoundsWithScreenEdgeVisible) { |
| 154 // Create a window with bounds that fill the screen. | 155 // Create a window with bounds that fill the screen. |
| 155 gfx::Rect bounds = gfx::Screen::GetPrimaryMonitorBounds(); | 156 gfx::Rect bounds = gfx::Screen::GetPrimaryMonitor()->GetBounds(); |
| 156 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 157 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
| 157 // Maximize it, which writes the old bounds to restore bounds. | 158 // Maximize it, which writes the old bounds to restore bounds. |
| 158 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 159 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 159 // Restore it. | 160 // Restore it. |
| 160 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 161 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 161 // It should have the default maximized window bounds, inset by the grid size. | 162 // It should have the default maximized window bounds, inset by the grid size. |
| 162 int grid_size = ash::Shell::GetInstance()->GetGridSize(); | 163 int grid_size = ash::Shell::GetInstance()->GetGridSize(); |
| 163 gfx::Rect max_bounds = ash::ScreenAsh::GetMaximizedWindowBounds(window.get()); | 164 gfx::Rect max_bounds = ash::ScreenAsh::GetMaximizedWindowBounds(window.get()); |
| 164 max_bounds.Inset(grid_size, grid_size); | 165 max_bounds.Inset(grid_size, grid_size); |
| 165 EXPECT_EQ(max_bounds.ToString(), window->bounds().ToString()); | 166 EXPECT_EQ(max_bounds.ToString(), window->bounds().ToString()); |
| 166 } | 167 } |
| 167 | 168 |
| 168 } // namespace | 169 } // namespace |
| 169 | 170 |
| 170 } // namespace ash | 171 } // namespace ash |
| OLD | NEW |