Commit 78e2fe93 authored by skuhne@chromium.org's avatar skuhne@chromium.org

Zzipping windows into the work area upon creation


BUG=122139
TEST=Unittest


Review URL: http://codereview.chromium.org/10091008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132491 0039d316-1c4b-4281-b951-d872f2087c98
parent ca8d144f
......@@ -171,6 +171,17 @@ void WindowSizer::DetermineWindowBounds(const gfx::Rect& specified_bounds,
GetDefaultWindowBounds(bounds);
}
}
} else {
// In case that there was a bound given we need to make sure that it is
// visible and fits on the screen.
// Find the size of the work area of the monitor that intersects the bounds
// of the anchor window. Note: AdjustBoundsToBeVisibleOnMonitorContaining
// does not exactly what we want: It makes only sure that "a minimal part"
// is visible on the screen.
gfx::Rect work_area =
monitor_info_provider_->GetMonitorWorkAreaMatching(*bounds);
// Resize so that it fits.
*bounds = bounds->AdjustToFit(work_area);
}
}
......
......@@ -89,7 +89,7 @@ TEST_F(WindowSizerTest, DefaultSizeCase) {
{ // 4:3 monitor case, 1024x768, no taskbar
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(),
gfx::Rect(), DEFAULT, &window_bounds, NULL);
gfx::Rect(), DEFAULT, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize,
WindowSizer::kDesktopBorderSize,
1024 - WindowSizer::kDesktopBorderSize * 2,
......@@ -100,7 +100,8 @@ TEST_F(WindowSizerTest, DefaultSizeCase) {
{ // 4:3 monitor case, 1024x768, taskbar on bottom
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, taskbar_bottom_work_area, gfx::Rect(),
gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL);
gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL,
gfx::Rect());
EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize,
WindowSizer::kDesktopBorderSize,
1024 - WindowSizer::kDesktopBorderSize * 2,
......@@ -113,7 +114,8 @@ TEST_F(WindowSizerTest, DefaultSizeCase) {
{ // 4:3 monitor case, 1024x768, taskbar on right
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, taskbar_right_work_area, gfx::Rect(),
gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL);
gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL,
gfx::Rect());
EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize,
WindowSizer::kDesktopBorderSize,
ash::WindowResizer::AlignToGridRoundDown(
......@@ -126,7 +128,8 @@ TEST_F(WindowSizerTest, DefaultSizeCase) {
{ // 4:3 monitor case, 1024x768, taskbar on left
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(),
gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL);
gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL,
gfx::Rect());
EXPECT_EQ(gfx::Rect(taskbar_left_work_area.x() +
WindowSizer::kDesktopBorderSize,
WindowSizer::kDesktopBorderSize,
......@@ -142,7 +145,8 @@ TEST_F(WindowSizerTest, DefaultSizeCase) {
{ // 4:3 monitor case, 1024x768, taskbar on top
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, taskbar_top_work_area, gfx::Rect(),
gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL);
gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL,
gfx::Rect());
EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize,
taskbar_top_work_area.y() +
WindowSizer::kDesktopBorderSize,
......@@ -156,7 +160,7 @@ TEST_F(WindowSizerTest, DefaultSizeCase) {
{ // 4:3 monitor case, 1280x1024
gfx::Rect window_bounds;
GetWindowBounds(twelveeighty, twelveeighty, gfx::Rect(), gfx::Rect(),
gfx::Rect(), DEFAULT, &window_bounds, NULL);
gfx::Rect(), DEFAULT, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize,
WindowSizer::kDesktopBorderSize,
1280 - 2 * WindowSizer::kDesktopBorderSize,
......@@ -167,7 +171,7 @@ TEST_F(WindowSizerTest, DefaultSizeCase) {
{ // 4:3 monitor case, 1600x1200
gfx::Rect window_bounds;
GetWindowBounds(sixteenhundred, sixteenhundred, gfx::Rect(), gfx::Rect(),
gfx::Rect(), DEFAULT, &window_bounds, NULL);
gfx::Rect(), DEFAULT, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect((1600 - 1280) / 2, WindowSizer::kDesktopBorderSize,
1280,
1200 - WindowSizer::kDesktopBorderSize),
......@@ -177,7 +181,7 @@ TEST_F(WindowSizerTest, DefaultSizeCase) {
{ // 16:10 monitor case, 1680x1050
gfx::Rect window_bounds;
GetWindowBounds(sixteeneighty, sixteeneighty, gfx::Rect(), gfx::Rect(),
gfx::Rect(), DEFAULT, &window_bounds, NULL);
gfx::Rect(), DEFAULT, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect((1680 - 1280) / 2, WindowSizer::kDesktopBorderSize,
1280,
ash::WindowResizer::AlignToGridRoundDown(
......@@ -189,7 +193,7 @@ TEST_F(WindowSizerTest, DefaultSizeCase) {
{ // 16:10 monitor case, 1920x1200
gfx::Rect window_bounds;
GetWindowBounds(nineteentwenty, nineteentwenty, gfx::Rect(), gfx::Rect(),
gfx::Rect(), DEFAULT, &window_bounds, NULL);
gfx::Rect(), DEFAULT, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect((1920 - 1280) / 2, WindowSizer::kDesktopBorderSize,
1280,
1200 - WindowSizer::kDesktopBorderSize),
......@@ -205,7 +209,8 @@ TEST_F(WindowSizerTest, LastWindowBoundsCase) {
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(WindowSizer::kDesktopBorderSize,
WindowSizer::kDesktopBorderSize, 500, 400),
gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL);
gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL,
gfx::Rect());
EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize,
kWindowTilePixels + WindowSizer::kDesktopBorderSize,
500, 400),
......@@ -217,7 +222,8 @@ TEST_F(WindowSizerTest, LastWindowBoundsCase) {
GetWindowBounds(tentwentyfour, taskbar_top_work_area, gfx::Rect(),
gfx::Rect(WindowSizer::kDesktopBorderSize,
WindowSizer::kDesktopBorderSize, 500, 400),
gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL);
gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL,
gfx::Rect());
EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize,
std::max(kWindowTilePixels +
WindowSizer::kDesktopBorderSize,
......@@ -230,7 +236,8 @@ TEST_F(WindowSizerTest, LastWindowBoundsCase) {
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(WindowSizer::kDesktopBorderSize,
WindowSizer::kDesktopBorderSize, 29, 29),
gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL);
gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL,
gfx::Rect());
EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize,
kWindowTilePixels + WindowSizer::kDesktopBorderSize,
30 /* not 29 */,
......@@ -244,7 +251,8 @@ TEST_F(WindowSizerTest, LastWindowBoundsCase) {
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(WindowSizer::kDesktopBorderSize,
WindowSizer::kDesktopBorderSize, 500, 400),
gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL);
gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL,
gfx::Rect());
EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize,
kWindowTilePixels + WindowSizer::kDesktopBorderSize,
500, 400),
......@@ -260,7 +268,7 @@ TEST_F(WindowSizerTest, PersistedBoundsCase) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), initial_bounds,
gfx::Rect(), PERSISTED, &window_bounds, NULL);
gfx::Rect(), PERSISTED, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(initial_bounds, window_bounds);
}
......@@ -269,7 +277,7 @@ TEST_F(WindowSizerTest, PersistedBoundsCase) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), initial_bounds,
gfx::Rect(), PERSISTED, &window_bounds, NULL);
gfx::Rect(), PERSISTED, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(initial_bounds, window_bounds);
}
......@@ -279,7 +287,7 @@ TEST_F(WindowSizerTest, PersistedBoundsCase) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary,
initial_bounds, gfx::Rect(), PERSISTED, &window_bounds,
NULL);
NULL, gfx::Rect());
EXPECT_EQ(initial_bounds, window_bounds);
}
......@@ -289,7 +297,7 @@ TEST_F(WindowSizerTest, PersistedBoundsCase) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary,
initial_bounds, gfx::Rect(), PERSISTED, &window_bounds,
NULL);
NULL, gfx::Rect());
EXPECT_EQ(initial_bounds, window_bounds);
}
......@@ -301,7 +309,7 @@ TEST_F(WindowSizerTest, PersistedBoundsCase) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600),
initial_bounds, right_nonprimary, PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(initial_bounds, window_bounds);
}
......@@ -313,7 +321,7 @@ TEST_F(WindowSizerTest, PersistedBoundsCase) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600),
initial_bounds, right_nonprimary, PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(1224, 50, 600, 500), window_bounds);
}
......@@ -325,7 +333,7 @@ TEST_F(WindowSizerTest, PersistedBoundsCase) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600),
initial_bounds, right_nonprimary, PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(1024, 0, 800, 600), window_bounds);
}
......@@ -334,7 +342,7 @@ TEST_F(WindowSizerTest, PersistedBoundsCase) {
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(WindowSizer::kDesktopBorderSize,
WindowSizer::kDesktopBorderSize, 29, 29),
gfx::Rect(), PERSISTED, &window_bounds, NULL);
gfx::Rect(), PERSISTED, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize,
WindowSizer::kDesktopBorderSize,
30 /* not 29 */, 30 /* not 29 */),
......@@ -354,7 +362,8 @@ TEST_F(WindowSizerTest, LastWindowOffscreenWithNonAggressiveRepositioning) {
GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(),
gfx::Rect(WindowSizer::kDesktopBorderSize,
WindowSizer::kDesktopBorderSize, 500, 400),
gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL);
gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL,
gfx::Rect());
EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize,
kWindowTilePixels + WindowSizer::kDesktopBorderSize,
500, 400),
......@@ -366,7 +375,7 @@ TEST_F(WindowSizerTest, LastWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(10, 728, 500, 400), gfx::Rect(), LAST_ACTIVE,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 738,
500, 400), window_bounds);
}
......@@ -376,7 +385,7 @@ TEST_F(WindowSizerTest, LastWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(10, 729, 500, 400), gfx::Rect(), LAST_ACTIVE,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 738 /* not 739 */, 500, 400),
window_bounds);
}
......@@ -386,7 +395,7 @@ TEST_F(WindowSizerTest, LastWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(984, 10, 500, 400), gfx::Rect(), LAST_ACTIVE,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(994, 10 + kWindowTilePixels, 500, 400), window_bounds);
}
......@@ -395,7 +404,7 @@ TEST_F(WindowSizerTest, LastWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(985, 10, 500, 400), gfx::Rect(), LAST_ACTIVE,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(994 /* not 995 */, 10 + kWindowTilePixels,
500, 400), window_bounds);
}
......@@ -405,7 +414,7 @@ TEST_F(WindowSizerTest, LastWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(985, 729, 500, 400), gfx::Rect(), LAST_ACTIVE,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(994 /* not 995 */, 738 /* not 739 */, 500, 400),
window_bounds);
}
......@@ -420,7 +429,7 @@ TEST_F(WindowSizerTest,
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
initial_bounds, gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(initial_bounds, window_bounds);
}
......@@ -429,7 +438,7 @@ TEST_F(WindowSizerTest,
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(-471, 50, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 50, 500, 400), window_bounds);
}
......@@ -439,7 +448,7 @@ TEST_F(WindowSizerTest,
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(50, -370, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds);
}
......@@ -450,7 +459,7 @@ TEST_F(WindowSizerTest,
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
initial_bounds, gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(initial_bounds, window_bounds);
}
......@@ -459,7 +468,7 @@ TEST_F(WindowSizerTest,
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(995, 50, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(994 /* not 995 */, 50, 500, 400), window_bounds);
}
......@@ -470,7 +479,7 @@ TEST_F(WindowSizerTest,
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
initial_bounds, gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(initial_bounds, window_bounds);
}
......@@ -479,7 +488,7 @@ TEST_F(WindowSizerTest,
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(50, 739, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(50, 738 /* not 739 */, 500, 400), window_bounds);
}
......@@ -487,7 +496,7 @@ TEST_F(WindowSizerTest,
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(-471, -371, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 0, 500, 400),
window_bounds);
}
......@@ -497,7 +506,7 @@ TEST_F(WindowSizerTest,
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(995, -371, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(994 /* not 995 */, 0, 500, 400),
window_bounds);
}
......@@ -507,7 +516,7 @@ TEST_F(WindowSizerTest,
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(-471, 739, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 738 /* not 739 */, 500, 400),
window_bounds);
}
......@@ -517,7 +526,7 @@ TEST_F(WindowSizerTest,
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(995, 739, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(994 /* not 995 */, 738 /* not 739 */, 500, 400),
window_bounds);
}
......@@ -526,7 +535,7 @@ TEST_F(WindowSizerTest,
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(-700, 50, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(-470 /* not -700 */, 50, 500, 400), window_bounds);
}
......@@ -534,7 +543,7 @@ TEST_F(WindowSizerTest,
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(-700, 50, 500, 400), left_nonprimary, PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(0, 50, 500, 400), window_bounds);
}
......@@ -542,7 +551,7 @@ TEST_F(WindowSizerTest,
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(50, -500, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds);
}
......@@ -550,7 +559,7 @@ TEST_F(WindowSizerTest,
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(50, -500, 500, 400), top_nonprimary,
PERSISTED, &window_bounds, NULL);
PERSISTED, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds);
}
......@@ -558,7 +567,7 @@ TEST_F(WindowSizerTest,
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(1200, 50, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(994 /* not 1200 */, 50, 500, 400), window_bounds);
}
......@@ -566,7 +575,7 @@ TEST_F(WindowSizerTest,
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(1200, 50, 500, 400), right_nonprimary,
PERSISTED, &window_bounds, NULL);
PERSISTED, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(524, 50, 500, 400), window_bounds);
}
......@@ -574,7 +583,7 @@ TEST_F(WindowSizerTest,
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(50, 800, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(50, 738 /* not 800 */, 500, 400), window_bounds);
}
......@@ -582,7 +591,7 @@ TEST_F(WindowSizerTest,
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(50, 800, 500, 400), bottom_nonprimary,
PERSISTED, &window_bounds, NULL);
PERSISTED, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(50, 368, 500, 400), window_bounds);
}
}
......@@ -648,7 +657,7 @@ TEST_F(WindowSizerTestWithBrowser, PlaceNewWindowOverOldWindow) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(50, 100, 300, 150), bottom_nonprimary,
PERSISTED, &window_bounds, browser.get());
PERSISTED, &window_bounds, browser.get(), gfx::Rect());
EXPECT_EQ(gfx::Rect(16, 32, 640, 320), window_bounds);
}
......@@ -656,7 +665,8 @@ TEST_F(WindowSizerTestWithBrowser, PlaceNewWindowOverOldWindow) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(50, 100, 300, 150), bottom_nonprimary,
PERSISTED, &window_bounds, popup_owning_browser.get());
PERSISTED, &window_bounds, popup_owning_browser.get(),
gfx::Rect());
EXPECT_EQ(gfx::Rect(50, 100, 300, 150), window_bounds);
}
......@@ -666,7 +676,7 @@ TEST_F(WindowSizerTestWithBrowser, PlaceNewWindowOverOldWindow) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(50, 100, 300, 150), bottom_nonprimary,
PERSISTED, &window_bounds, browser.get());
PERSISTED, &window_bounds, browser.get(), gfx::Rect());
EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize,
WindowSizer::kDesktopBorderSize,
1024 - 2 * WindowSizer::kDesktopBorderSize,
......@@ -674,3 +684,24 @@ TEST_F(WindowSizerTestWithBrowser, PlaceNewWindowOverOldWindow) {
window_bounds);
}
}
// Test that the window is sized appropriately for the first run experience
// where the default window bounds calculation is invoked.
TEST_F(WindowSizerTest, AdjustFitSize) {
{ // Check that the window gets resized to the screen.
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(),
gfx::Rect(), DEFAULT, &window_bounds, NULL,
gfx::Rect(-10, -10, 1024 + 20, 768 + 20));
EXPECT_EQ(gfx::Rect(0, 0, 1024, 768), window_bounds);
}
{ // Check that a window which hangs out of the screen get moved back in.
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(),
gfx::Rect(), DEFAULT, &window_bounds, NULL,
gfx::Rect(1020, 700, 100, 100));
EXPECT_EQ(gfx::Rect(924, 668, 100, 100), window_bounds);
}
}
......@@ -176,7 +176,8 @@ static void GetWindowBounds(const gfx::Rect& monitor1_bounds,
const gfx::Rect& work_area,
Source source,
gfx::Rect* out_bounds,
const Browser* browser) {
const Browser* browser,
const gfx::Rect& passed_in) {
TestMonitorInfoProvider* mip = new TestMonitorInfoProvider;
mip->AddMonitor(monitor1_bounds, monitor1_work_area);
if (!monitor2_bounds.IsEmpty())
......@@ -188,7 +189,7 @@ static void GetWindowBounds(const gfx::Rect& monitor1_bounds,
sp->SetLastActiveState(state, true);
WindowSizer sizer(sp, mip, browser);
sizer.DetermineWindowBounds(gfx::Rect(), out_bounds);
sizer.DetermineWindowBounds(passed_in, out_bounds);
}
#endif // CHROME_BROWSER_UI_WINDOW_SIZER_COMMON_UNITTEST_H_
......@@ -17,7 +17,7 @@ TEST(WindowSizerTest, DefaultSizeCase) {
{ // 4:3 monitor case, 1024x768, no taskbar
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(),
gfx::Rect(), DEFAULT, &window_bounds, NULL);
gfx::Rect(), DEFAULT, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels,
1024 - kWindowTilePixels * 2,
768 - kWindowTilePixels * 2),
......@@ -27,7 +27,8 @@ TEST(WindowSizerTest, DefaultSizeCase) {
{ // 4:3 monitor case, 1024x768, taskbar on bottom
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, taskbar_bottom_work_area, gfx::Rect(),
gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL);
gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL,
gfx::Rect());
EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels,
1024 - kWindowTilePixels * 2,
(taskbar_bottom_work_area.height() -
......@@ -38,7 +39,8 @@ TEST(WindowSizerTest, DefaultSizeCase) {
{ // 4:3 monitor case, 1024x768, taskbar on right
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, taskbar_right_work_area, gfx::Rect(),
gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL);
gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL,
gfx::Rect());
EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels,
taskbar_right_work_area.width() - kWindowTilePixels*2,
768 - kWindowTilePixels * 2),
......@@ -48,7 +50,8 @@ TEST(WindowSizerTest, DefaultSizeCase) {
{ // 4:3 monitor case, 1024x768, taskbar on left
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(),
gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL);
gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL,
gfx::Rect());
EXPECT_EQ(gfx::Rect(taskbar_left_work_area.x() + kWindowTilePixels,
kWindowTilePixels,
taskbar_left_work_area.width() - kWindowTilePixels * 2,
......@@ -60,7 +63,8 @@ TEST(WindowSizerTest, DefaultSizeCase) {
{ // 4:3 monitor case, 1024x768, taskbar on top
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, taskbar_top_work_area, gfx::Rect(),
gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL);
gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL,
gfx::Rect());
EXPECT_EQ(gfx::Rect(kWindowTilePixels,
taskbar_top_work_area.y() + kWindowTilePixels,
1024 - kWindowTilePixels * 2,
......@@ -71,7 +75,7 @@ TEST(WindowSizerTest, DefaultSizeCase) {
{ // 4:3 monitor case, 1280x1024
gfx::Rect window_bounds;
GetWindowBounds(twelveeighty, twelveeighty, gfx::Rect(), gfx::Rect(),
gfx::Rect(), DEFAULT, &window_bounds, NULL);
gfx::Rect(), DEFAULT, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels,
1050,
1024 - kWindowTilePixels * 2),
......@@ -81,7 +85,7 @@ TEST(WindowSizerTest, DefaultSizeCase) {
{ // 4:3 monitor case, 1600x1200
gfx::Rect window_bounds;
GetWindowBounds(sixteenhundred, sixteenhundred, gfx::Rect(), gfx::Rect(),
gfx::Rect(), DEFAULT, &window_bounds, NULL);
gfx::Rect(), DEFAULT, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels,
1050,
1200 - kWindowTilePixels * 2),
......@@ -91,7 +95,7 @@ TEST(WindowSizerTest, DefaultSizeCase) {
{ // 16:10 monitor case, 1680x1050
gfx::Rect window_bounds;
GetWindowBounds(sixteeneighty, sixteeneighty, gfx::Rect(), gfx::Rect(),
gfx::Rect(), DEFAULT, &window_bounds, NULL);
gfx::Rect(), DEFAULT, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels,
840 - static_cast<int>(kWindowTilePixels * 1.5),
1050 - kWindowTilePixels * 2),
......@@ -101,7 +105,7 @@ TEST(WindowSizerTest, DefaultSizeCase) {
{ // 16:10 monitor case, 1920x1200
gfx::Rect window_bounds;
GetWindowBounds(nineteentwenty, nineteentwenty, gfx::Rect(), gfx::Rect(),
gfx::Rect(), DEFAULT, &window_bounds, NULL);
gfx::Rect(), DEFAULT, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels,
960 - static_cast<int>(kWindowTilePixels * 1.5),
1200 - kWindowTilePixels * 2),
......@@ -116,7 +120,8 @@ TEST(WindowSizerTest, LastWindowBoundsCase) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400),
gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL);
gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL,
gfx::Rect());
EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2,
kWindowTilePixels * 2, 500, 400), window_bounds);
}
......@@ -125,7 +130,8 @@ TEST(WindowSizerTest, LastWindowBoundsCase) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, taskbar_top_work_area, gfx::Rect(),
gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400),
gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL);
gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL,
gfx::Rect());
EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2,
std::max(kWindowTilePixels * 2,
34 /* toolbar height */),
......@@ -136,7 +142,8 @@ TEST(WindowSizerTest, LastWindowBoundsCase) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(kWindowTilePixels, kWindowTilePixels, 29, 29),
gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL);
gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL,
gfx::Rect());
EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2,
kWindowTilePixels * 2,
30 /* not 29 */,
......@@ -149,7 +156,8 @@ TEST(WindowSizerTest, LastWindowBoundsCase) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400),
gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL);
gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL,
gfx::Rect());
EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2,
kWindowTilePixels * 2, 500, 400), window_bounds);
}
......@@ -162,7 +170,7 @@ TEST(WindowSizerTest, PersistedBoundsCase) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), initial_bounds,
gfx::Rect(), PERSISTED, &window_bounds, NULL);
gfx::Rect(), PERSISTED, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(initial_bounds, window_bounds);
}
......@@ -171,7 +179,7 @@ TEST(WindowSizerTest, PersistedBoundsCase) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), initial_bounds,
gfx::Rect(), PERSISTED, &window_bounds, NULL);
gfx::Rect(), PERSISTED, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(initial_bounds, window_bounds);
}
......@@ -181,7 +189,7 @@ TEST(WindowSizerTest, PersistedBoundsCase) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary,
initial_bounds, gfx::Rect(), PERSISTED, &window_bounds,
NULL);
NULL, gfx::Rect());
EXPECT_EQ(initial_bounds, window_bounds);
}
......@@ -191,7 +199,7 @@ TEST(WindowSizerTest, PersistedBoundsCase) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary,
initial_bounds, gfx::Rect(), PERSISTED, &window_bounds,
NULL);
NULL, gfx::Rect());
EXPECT_EQ(initial_bounds, window_bounds);
}
......@@ -203,7 +211,7 @@ TEST(WindowSizerTest, PersistedBoundsCase) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600),
initial_bounds, right_nonprimary, PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(initial_bounds, window_bounds);
}
......@@ -215,7 +223,7 @@ TEST(WindowSizerTest, PersistedBoundsCase) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600),
initial_bounds, right_nonprimary, PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(1224, 50, 600, 500), window_bounds);
}
......@@ -227,7 +235,7 @@ TEST(WindowSizerTest, PersistedBoundsCase) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600),
initial_bounds, right_nonprimary, PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(1024, 0, 800, 600), window_bounds);
}
......@@ -235,7 +243,7 @@ TEST(WindowSizerTest, PersistedBoundsCase) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(kWindowTilePixels, kWindowTilePixels, 29, 29),
gfx::Rect(), PERSISTED, &window_bounds, NULL);
gfx::Rect(), PERSISTED, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels,
30 /* not 29 */, 30 /* not 29 */),
window_bounds);
......@@ -249,7 +257,7 @@ TEST(WindowSizerTest, PersistedBoundsCase) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(kWindowTilePixels, kWindowTilePixels, 30, 5000),
gfx::Rect(), PERSISTED, &window_bounds, NULL);
gfx::Rect(), PERSISTED, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(tentwentyfour.height(), window_bounds.height());
}
#endif // defined(OS_MACOSX)
......@@ -268,7 +276,8 @@ TEST(WindowSizerTest, LastWindowOffscreenWithAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(),
gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400),
gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL);
gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL,
gfx::Rect());
EXPECT_EQ(gfx::Rect(taskbar_left_work_area.x(),
kWindowTilePixels * 2, 500, 400), window_bounds);
}
......@@ -277,7 +286,7 @@ TEST(WindowSizerTest, LastWindowOffscreenWithAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(10, 729, 500, 400), gfx::Rect(), LAST_ACTIVE,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels,
0 /* not 729 + kWindowTilePixels */,
500, 400),
......@@ -288,7 +297,7 @@ TEST(WindowSizerTest, LastWindowOffscreenWithAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(985, 10, 500, 400), gfx::Rect(), LAST_ACTIVE,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(0 /* not 985 + kWindowTilePixels*/,
10 + kWindowTilePixels,
500, 400),
......@@ -299,7 +308,7 @@ TEST(WindowSizerTest, LastWindowOffscreenWithAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(985, 729, 500, 400), gfx::Rect(), LAST_ACTIVE,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(0 /* not 985 + kWindowTilePixels*/,
0 /* not 729 + kWindowTilePixels*/,
500, 400),
......@@ -312,7 +321,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(-471, 50, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(0 /* not -471 */, 50, 500, 400), window_bounds);
}
......@@ -320,7 +329,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(50, -370, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds);
}
......@@ -328,7 +337,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(995, 50, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(0 /* not 995 */, 50, 500, 400), window_bounds);
}
......@@ -336,7 +345,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(50, 739, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(50, 0 /* not 739 */, 500, 400), window_bounds);
}
......@@ -344,7 +353,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(-471, -371, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(0 /* not -471 */, 0 /* not -371 */, 500, 400),
window_bounds);
}
......@@ -353,7 +362,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(995, -371, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(0 /* not 995 */, 0 /* not -371 */, 500, 400),
window_bounds);
}
......@@ -362,7 +371,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(-471, 739, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(0 /* not -471 */, 0 /* not 739 */, 500, 400),
window_bounds);
}
......@@ -371,7 +380,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(995, 739, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(0 /* not 995 */, 0 /* not 739 */, 500, 400),
window_bounds);
}
......@@ -380,7 +389,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(-700, 50, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(0 /* not -700 */, 50, 500, 400), window_bounds);
}
......@@ -388,7 +397,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(-700, 50, 500, 400), left_nonprimary,
PERSISTED, &window_bounds, NULL);
PERSISTED, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(0, 50, 500, 400), window_bounds);
}
......@@ -396,7 +405,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(50, -500, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds);
}
......@@ -404,7 +413,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(50, -500, 500, 400), top_nonprimary, PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds);
}
......@@ -412,7 +421,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(1200, 50, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(0 /* not 1200 */, 50, 500, 400), window_bounds);
}
......@@ -420,7 +429,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(1200, 50, 500, 400), right_nonprimary, PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(524 /* not 1200 */, 50, 500, 400), window_bounds);
}
......@@ -428,7 +437,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(50, 800, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(50, 0 /* not 800 */, 500, 400), window_bounds);
}
......@@ -436,7 +445,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(50, 800, 500, 400), bottom_nonprimary,
PERSISTED, &window_bounds, NULL);
PERSISTED, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(50, 368 /* not 800 */, 500, 400), window_bounds);
}
......@@ -444,7 +453,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(-100, 50, 2000, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(0 /* not -100 */, 50, 2000, 400), window_bounds);
}
}
......@@ -454,7 +463,8 @@ TEST(WindowSizerTest, LastWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(),
gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400),
gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL);
gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL,
gfx::Rect());
EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2,
kWindowTilePixels * 2, 500, 400), window_bounds);
}
......@@ -466,7 +476,7 @@ TEST(WindowSizerTest, LastWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(10, 728, 500, 400), gfx::Rect(), LAST_ACTIVE,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 738,
500, 400), window_bounds);
}
......@@ -476,7 +486,7 @@ TEST(WindowSizerTest, LastWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(10, 729, 500, 400), gfx::Rect(), LAST_ACTIVE,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 738 /* not 739 */, 500, 400),
window_bounds);
}
......@@ -486,7 +496,7 @@ TEST(WindowSizerTest, LastWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(984, 10, 500, 400), gfx::Rect(), LAST_ACTIVE,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(994, 10 + kWindowTilePixels, 500, 400), window_bounds);
}
......@@ -495,7 +505,7 @@ TEST(WindowSizerTest, LastWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(985, 10, 500, 400), gfx::Rect(), LAST_ACTIVE,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(994 /* not 995 */, 10 + kWindowTilePixels,
500, 400), window_bounds);
}
......@@ -505,7 +515,7 @@ TEST(WindowSizerTest, LastWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(985, 729, 500, 400), gfx::Rect(), LAST_ACTIVE,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(994 /* not 995 */, 738 /* not 739 */, 500, 400),
window_bounds);
}
......@@ -520,7 +530,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
initial_bounds, gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(initial_bounds, window_bounds);
}
......@@ -529,7 +539,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(-471, 50, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 50, 500, 400), window_bounds);
}
......@@ -539,7 +549,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(50, -370, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds);
}
......@@ -550,7 +560,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
initial_bounds, gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(initial_bounds, window_bounds);
}
......@@ -559,7 +569,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(995, 50, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(994 /* not 995 */, 50, 500, 400), window_bounds);
}
......@@ -570,7 +580,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
initial_bounds, gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(initial_bounds, window_bounds);
}
......@@ -579,7 +589,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(50, 739, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(50, 738 /* not 739 */, 500, 400), window_bounds);
}
......@@ -587,7 +597,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(-471, -371, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 0, 500, 400),
window_bounds);
}
......@@ -597,7 +607,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(995, -371, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(994 /* not 995 */, 0, 500, 400),
window_bounds);
}
......@@ -607,7 +617,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(-471, 739, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 738 /* not 739 */, 500, 400),
window_bounds);
}
......@@ -617,7 +627,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(995, 739, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(994 /* not 995 */, 738 /* not 739 */, 500, 400),
window_bounds);
}
......@@ -626,7 +636,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(-700, 50, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(-470 /* not -700 */, 50, 500, 400), window_bounds);
}
......@@ -634,7 +644,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(-700, 50, 500, 400), left_nonprimary, PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(0, 50, 500, 400), window_bounds);
}
......@@ -642,7 +652,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(50, -500, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds);
}
......@@ -650,7 +660,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(50, -500, 500, 400), top_nonprimary,
PERSISTED, &window_bounds, NULL);
PERSISTED, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds);
}
......@@ -658,7 +668,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(1200, 50, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(994 /* not 1200 */, 50, 500, 400), window_bounds);
}
......@@ -666,7 +676,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(1200, 50, 500, 400), right_nonprimary,
PERSISTED, &window_bounds, NULL);
PERSISTED, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(524, 50, 500, 400), window_bounds);
}
......@@ -674,7 +684,7 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(50, 800, 500, 400), gfx::Rect(), PERSISTED,
&window_bounds, NULL);
&window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(50, 738 /* not 800 */, 500, 400), window_bounds);
}
......@@ -682,8 +692,29 @@ TEST(WindowSizerTest, PersistedWindowOffscreenWithNonAggressiveRepositioning) {
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
gfx::Rect(50, 800, 500, 400), bottom_nonprimary,
PERSISTED, &window_bounds, NULL);
PERSISTED, &window_bounds, NULL, gfx::Rect());
EXPECT_EQ(gfx::Rect(50, 368, 500, 400), window_bounds);
}
}
// Test that the window is sized appropriately for the first run experience
// where the default window bounds calculation is invoked.
TEST(WindowSizerTest, AdjustFitSize) {
{ // Check that the window gets resized to the screen.
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(),
gfx::Rect(), DEFAULT, &window_bounds, NULL,
gfx::Rect(-10, -10, 1024 + 20, 768 + 20));
EXPECT_EQ(gfx::Rect(0, 0, 1024, 768), window_bounds);
}
{ // Check that a window which hangs out of the screen get moved back in.
gfx::Rect window_bounds;
GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(),
gfx::Rect(), DEFAULT, &window_bounds, NULL,
gfx::Rect(1020, 700, 100, 100));
EXPECT_EQ(gfx::Rect(924, 668, 100, 100), window_bounds);
}
}
#endif //defined(OS_MACOSX)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment