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..3be55338ec2267d5576edccf83a8875470716255 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 { |
@@ -112,7 +120,10 @@ WindowPositionerTest::WindowPositionerTest() |
profile_.reset(new TestingProfile()); |
} |
-WindowPositionerTest::~WindowPositionerTest() {} |
+WindowPositionerTest::~WindowPositionerTest() { |
+ profile_.reset(NULL); |
+ ui_thread_.reset(NULL); |
+} |
void WindowPositionerTest::SetUp() { |
AshTestBase::SetUp(); |
@@ -251,7 +262,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(), |
@@ -270,20 +281,22 @@ TEST_F(WindowPositionerTest, filling) { |
popup()->Show(); |
gfx::Rect mid_left = window_positioner()->GetPopupPosition(popup_position); |
EXPECT_EQ(gfx::Rect(work_area.x(), |
- work_area.y() + top_left.height(), |
+ align(work_area.y() + top_left.height(), grid), |
popup_position.width(), popup_position.height()), |
mid_left); |
// 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 +307,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); |