| 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/workspace/workspace_manager.h" | 5 #include "ash/wm/workspace/workspace_manager.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/screen_ash.h" | 8 #include "ash/screen_ash.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 83 } |
| 84 | 84 |
| 85 // Overridden from AshTestBase: | 85 // Overridden from AshTestBase: |
| 86 virtual void SetUp() OVERRIDE { | 86 virtual void SetUp() OVERRIDE { |
| 87 CommandLine::ForCurrentProcess()->AppendSwitch( | 87 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 88 switches::kAshDisableWorkspace2); | 88 switches::kAshDisableWorkspace2); |
| 89 test::AshTestBase::SetUp(); | 89 test::AshTestBase::SetUp(); |
| 90 WorkspaceControllerTestHelper workspace_helper( | 90 WorkspaceControllerTestHelper workspace_helper( |
| 91 Shell::TestApi(Shell::GetInstance()).workspace_controller()); | 91 Shell::TestApi(Shell::GetInstance()).workspace_controller()); |
| 92 manager_ = workspace_helper.workspace_manager(); | 92 manager_ = workspace_helper.workspace_manager(); |
| 93 manager_->SetGridSize(0); | |
| 94 } | 93 } |
| 95 virtual void TearDown() OVERRIDE { | 94 virtual void TearDown() OVERRIDE { |
| 96 manager_ = NULL; | 95 manager_ = NULL; |
| 97 test::AshTestBase::TearDown(); | 96 test::AshTestBase::TearDown(); |
| 98 } | 97 } |
| 99 | 98 |
| 100 protected: | 99 protected: |
| 101 WorkspaceManager* manager_; | 100 WorkspaceManager* manager_; |
| 102 | 101 |
| 103 private: | 102 private: |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 EXPECT_TRUE(manager_->ShouldManageWindow(w1.get())); | 307 EXPECT_TRUE(manager_->ShouldManageWindow(w1.get())); |
| 309 // Setting the bounds should go through since the window is in the normal | 308 // Setting the bounds should go through since the window is in the normal |
| 310 // workspace. | 309 // workspace. |
| 311 w1->SetBounds(gfx::Rect(0, 0, 200, 500)); | 310 w1->SetBounds(gfx::Rect(0, 0, 200, 500)); |
| 312 EXPECT_EQ(200, w1->bounds().width()); | 311 EXPECT_EQ(200, w1->bounds().width()); |
| 313 EXPECT_EQ(500, w1->bounds().height()); | 312 EXPECT_EQ(500, w1->bounds().height()); |
| 314 } | 313 } |
| 315 | 314 |
| 316 // Assertions around grid size. | 315 // Assertions around grid size. |
| 317 TEST_F(WorkspaceManagerTest, SnapToGrid) { | 316 TEST_F(WorkspaceManagerTest, SnapToGrid) { |
| 318 manager_->SetGridSize(8); | |
| 319 | |
| 320 // Verify snap to grid when bounds are set before parented. | 317 // Verify snap to grid when bounds are set before parented. |
| 321 scoped_ptr<Window> w1(CreateTestWindowUnparented()); | 318 scoped_ptr<Window> w1(CreateTestWindowUnparented()); |
| 322 w1->SetBounds(gfx::Rect(1, 6, 25, 30)); | 319 w1->SetBounds(gfx::Rect(1, 6, 25, 30)); |
| 323 w1->SetParent(GetViewport()); | 320 w1->SetParent(GetViewport()); |
| 324 // We are not aligning this anymore this way. When the window gets shown | 321 // We are not aligning this anymore this way. When the window gets shown |
| 325 // the window is expected to be handled differently, but this cannot be | 322 // the window is expected to be handled differently, but this cannot be |
| 326 // tested with this test. So the result of this test should be that the | 323 // tested with this test. So the result of this test should be that the |
| 327 // bounds are exactly as passed in. | 324 // bounds are exactly as passed in. |
| 328 EXPECT_EQ(gfx::Rect(1, 6, 25, 30), w1->bounds()); | 325 EXPECT_EQ(gfx::Rect(1, 6, 25, 30), w1->bounds()); |
| 329 } | 326 } |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 wm::ActivateWindow(w1.get()); | 731 wm::ActivateWindow(w1.get()); |
| 735 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 732 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 736 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 733 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
| 737 EXPECT_EQ(ShelfLayoutManager::VISIBLE, | 734 EXPECT_EQ(ShelfLayoutManager::VISIBLE, |
| 738 Shell::GetInstance()->shelf()->visibility_state()); | 735 Shell::GetInstance()->shelf()->visibility_state()); |
| 739 EXPECT_FALSE(Shell::GetInstance()->launcher()->paints_background()); | 736 EXPECT_FALSE(Shell::GetInstance()->launcher()->paints_background()); |
| 740 } | 737 } |
| 741 | 738 |
| 742 } // namespace internal | 739 } // namespace internal |
| 743 } // namespace ash | 740 } // namespace ash |
| OLD | NEW |