Index: chrome/browser/ui/ash/window_positioner_unittest.cc |
diff --git a/chrome/browser/ui/ash/window_positioner_unittest.cc b/chrome/browser/ui/ash/window_positioner_unittest.cc |
index c15d4efc9a0bc7d9750e84ee123e004b249e936c..52f35787a85c3251637946397840f11205a86096 100644 |
--- a/chrome/browser/ui/ash/window_positioner_unittest.cc |
+++ b/chrome/browser/ui/ash/window_positioner_unittest.cc |
@@ -76,7 +76,7 @@ class WindowPositionerTest : public AshTestBase { |
WindowPositioner* window_positioner() { return window_positioner_; } |
// The positioner & desktop's used grid alignment size. |
- int grid_size_; |
+ const int grid_size_; |
private: |
WindowPositioner* window_positioner_; |
@@ -102,7 +102,8 @@ class WindowPositionerTest : public AshTestBase { |
}; |
WindowPositionerTest::WindowPositionerTest() |
- : window_positioner_(NULL) { |
+ : grid_size_(WindowPositioner::kMinimumWindowOffset), |
+ window_positioner_(NULL) { |
// Create a message loop. |
MessageLoopForUI* ui_loop = message_loop(); |
ui_thread_.reset( |
@@ -150,15 +151,6 @@ void WindowPositionerTest::SetUp() { |
popup()->Hide(); |
panel()->Hide(); |
window_positioner_ = new WindowPositioner(); |
- |
- // Get the alignment size. |
- grid_size_ = ash::Shell::GetInstance()->GetGridSize(); |
- if (!grid_size_) { |
- grid_size_ = WindowPositioner::kMinimumWindowOffset; |
- } else { |
- while (grid_size_ < WindowPositioner::kMinimumWindowOffset) |
- grid_size_ *= 2; |
- } |
} |
void WindowPositionerTest::TearDown() { |
@@ -181,6 +173,12 @@ void WindowPositionerTest::TearDown() { |
window_positioner_ = NULL; |
} |
+int AlignToGridRoundDown(int location, int grid_size) { |
+ if (grid_size <= 1 || location % grid_size == 0) |
+ return location; |
+ return location / grid_size * grid_size; |
+} |
+ |
TEST_F(WindowPositionerTest, cascading) { |
const gfx::Rect work_area = gfx::Screen::GetPrimaryDisplay().work_area(); |
@@ -243,7 +241,6 @@ TEST_F(WindowPositionerTest, cascading) { |
TEST_F(WindowPositionerTest, filling) { |
const gfx::Rect work_area = gfx::Screen::GetPrimaryDisplay().work_area(); |
- int grid = ash::Shell::GetInstance()->GetGridSize(); |
gfx::Rect popup_position(0, 0, 256, 128); |
// Leave space on the left and the right and see if we fill top to bottom. |
window()->SetBounds(gfx::Rect(work_area.x() + popup_position.width(), |
@@ -262,8 +259,8 @@ TEST_F(WindowPositionerTest, filling) { |
popup()->Show(); |
gfx::Rect mid_left = window_positioner()->GetPopupPosition(popup_position); |
EXPECT_EQ(gfx::Rect(work_area.x(), |
- ash::WindowResizer::AlignToGridRoundDown( |
- work_area.y() + top_left.height(), grid), |
+ AlignToGridRoundDown( |
+ work_area.y() + top_left.height(), grid_size_), |
popup_position.width(), popup_position.height()), |
mid_left); |
@@ -274,7 +271,7 @@ TEST_F(WindowPositionerTest, filling) { |
popup()->SetBounds(gfx::Rect(work_area.x(), work_area.y(), |
popup_position.width(), |
work_area.height() - popup_position.height() - |
- grid + 1)); |
+ grid_size_ + 1)); |
gfx::Rect bottom_left = window_positioner()->GetPopupPosition( |
popup_position); |
EXPECT_EQ(gfx::Rect(work_area.x(), |
@@ -289,8 +286,8 @@ TEST_F(WindowPositionerTest, filling) { |
1)); |
gfx::Rect top_right = window_positioner()->GetPopupPosition( |
popup_position); |
- EXPECT_EQ(gfx::Rect(ash::WindowResizer::AlignToGridRoundDown( |
- work_area.right() - popup_position.width(), grid), |
+ EXPECT_EQ(gfx::Rect(AlignToGridRoundDown(work_area.right() - |
+ popup_position.width(), grid_size_), |
work_area.y(), |
popup_position.width(), popup_position.height()), |
top_right); |