Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(654)

Unified Diff: chrome/browser/ui/ash/window_positioner_unittest.cc

Issue 10910164: Removes the grid from ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ShelfBrowserTest Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/ash/window_positioner.cc ('k') | chrome/browser/ui/window_sizer/window_sizer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « chrome/browser/ui/ash/window_positioner.cc ('k') | chrome/browser/ui/window_sizer/window_sizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698