Index: chrome/browser/ui/views/ash/window_positioner_unittest.cc |
diff --git a/chrome/browser/ui/views/ash/window_positioner_unittest.cc b/chrome/browser/ui/views/ash/window_positioner_unittest.cc |
index 943f4bda771b47689e537ecffdcfb4e4f9aff88a..c108d3c469ce119c5d41ac3cc1ab7d6b5fbd178e 100644 |
--- a/chrome/browser/ui/views/ash/window_positioner_unittest.cc |
+++ b/chrome/browser/ui/views/ash/window_positioner_unittest.cc |
@@ -28,6 +28,14 @@ namespace test { |
namespace { |
+// A function which aligns a size to a step within the grid. |
+int align(int size, int alignment_factor) { |
+ if (alignment_factor > 1) { |
+ return size - size % alignment_factor; |
+ } |
+ return size; |
+} |
+ |
// A browser window proxy which is able to associate an aura native window with |
// it. |
class TestBrowserWindowAura : public TestBrowserWindow { |
@@ -251,7 +259,7 @@ TEST_F(WindowPositionerTest, cascading) { |
TEST_F(WindowPositionerTest, filling) { |
const gfx::Rect work_area = gfx::Screen::GetPrimaryMonitorWorkArea(); |
- |
+ 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(), |
@@ -276,14 +284,16 @@ TEST_F(WindowPositionerTest, filling) { |
// Block now everything so that we can only put the popup on the bottom |
// of the left side. |
+ // Note: We need to keep one "grid spacing free" if the window does not |
+ // fit into the grid (which is true for 200 height).` |
popup()->SetBounds(gfx::Rect(work_area.x(), work_area.y(), |
popup_position.width(), |
- work_area.height() - popup_position.height())); |
+ work_area.height() - popup_position.height() - |
+ grid + 1)); |
gfx::Rect bottom_left = window_positioner()->GetPopupPosition( |
popup_position); |
EXPECT_EQ(gfx::Rect(work_area.x(), |
- work_area.y() + work_area.height() - |
- popup_position.height(), |
+ work_area.bottom() - popup_position.height(), |
popup_position.width(), popup_position.height()), |
bottom_left); |
@@ -294,8 +304,8 @@ TEST_F(WindowPositionerTest, filling) { |
1)); |
gfx::Rect top_right = window_positioner()->GetPopupPosition( |
popup_position); |
- EXPECT_EQ(gfx::Rect(work_area.x() + work_area.width() - |
- popup_position.width(), |
+ EXPECT_EQ(gfx::Rect(align(work_area.right() - |
+ popup_position.width(), grid), |
work_area.y(), |
popup_position.width(), popup_position.height()), |
top_right); |