| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/window_sizer.h" | 5 #include "chrome/browser/ui/window_sizer.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "chrome/browser/ui/window_sizer_common_unittest.h" | 11 #include "chrome/browser/ui/window_sizer_common_unittest.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 // Test that the window is sized appropriately for the first run experience | 14 // Test that the window is sized appropriately for the first run experience |
| 15 // where the default window bounds calculation is invoked. | 15 // where the default window bounds calculation is invoked. |
| 16 TEST(WindowSizerTest, DefaultSizeCase) { | 16 TEST(WindowSizerTest, DefaultSizeCase) { |
| 17 { // 4:3 monitor case, 1024x768, no taskbar | 17 { // 4:3 monitor case, 1024x768, no taskbar |
| 18 gfx::Rect window_bounds; | 18 gfx::Rect window_bounds; |
| 19 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(), | 19 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(), |
| 20 gfx::Rect(), DEFAULT, &window_bounds, NULL); | 20 gfx::Rect(), DEFAULT, &window_bounds, NULL, gfx::Rect()); |
| 21 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, | 21 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, |
| 22 1024 - kWindowTilePixels * 2, | 22 1024 - kWindowTilePixels * 2, |
| 23 768 - kWindowTilePixels * 2), | 23 768 - kWindowTilePixels * 2), |
| 24 window_bounds); | 24 window_bounds); |
| 25 } | 25 } |
| 26 | 26 |
| 27 { // 4:3 monitor case, 1024x768, taskbar on bottom | 27 { // 4:3 monitor case, 1024x768, taskbar on bottom |
| 28 gfx::Rect window_bounds; | 28 gfx::Rect window_bounds; |
| 29 GetWindowBounds(tentwentyfour, taskbar_bottom_work_area, gfx::Rect(), | 29 GetWindowBounds(tentwentyfour, taskbar_bottom_work_area, gfx::Rect(), |
| 30 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL); | 30 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL, |
| 31 gfx::Rect()); |
| 31 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, | 32 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, |
| 32 1024 - kWindowTilePixels * 2, | 33 1024 - kWindowTilePixels * 2, |
| 33 (taskbar_bottom_work_area.height() - | 34 (taskbar_bottom_work_area.height() - |
| 34 kWindowTilePixels * 2)), | 35 kWindowTilePixels * 2)), |
| 35 window_bounds); | 36 window_bounds); |
| 36 } | 37 } |
| 37 | 38 |
| 38 { // 4:3 monitor case, 1024x768, taskbar on right | 39 { // 4:3 monitor case, 1024x768, taskbar on right |
| 39 gfx::Rect window_bounds; | 40 gfx::Rect window_bounds; |
| 40 GetWindowBounds(tentwentyfour, taskbar_right_work_area, gfx::Rect(), | 41 GetWindowBounds(tentwentyfour, taskbar_right_work_area, gfx::Rect(), |
| 41 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL); | 42 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL, |
| 43 gfx::Rect()); |
| 42 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, | 44 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, |
| 43 taskbar_right_work_area.width() - kWindowTilePixels*2, | 45 taskbar_right_work_area.width() - kWindowTilePixels*2, |
| 44 768 - kWindowTilePixels * 2), | 46 768 - kWindowTilePixels * 2), |
| 45 window_bounds); | 47 window_bounds); |
| 46 } | 48 } |
| 47 | 49 |
| 48 { // 4:3 monitor case, 1024x768, taskbar on left | 50 { // 4:3 monitor case, 1024x768, taskbar on left |
| 49 gfx::Rect window_bounds; | 51 gfx::Rect window_bounds; |
| 50 GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(), | 52 GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(), |
| 51 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL); | 53 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL, |
| 54 gfx::Rect()); |
| 52 EXPECT_EQ(gfx::Rect(taskbar_left_work_area.x() + kWindowTilePixels, | 55 EXPECT_EQ(gfx::Rect(taskbar_left_work_area.x() + kWindowTilePixels, |
| 53 kWindowTilePixels, | 56 kWindowTilePixels, |
| 54 taskbar_left_work_area.width() - kWindowTilePixels * 2, | 57 taskbar_left_work_area.width() - kWindowTilePixels * 2, |
| 55 (taskbar_left_work_area.height() - | 58 (taskbar_left_work_area.height() - |
| 56 kWindowTilePixels * 2)), | 59 kWindowTilePixels * 2)), |
| 57 window_bounds); | 60 window_bounds); |
| 58 } | 61 } |
| 59 | 62 |
| 60 { // 4:3 monitor case, 1024x768, taskbar on top | 63 { // 4:3 monitor case, 1024x768, taskbar on top |
| 61 gfx::Rect window_bounds; | 64 gfx::Rect window_bounds; |
| 62 GetWindowBounds(tentwentyfour, taskbar_top_work_area, gfx::Rect(), | 65 GetWindowBounds(tentwentyfour, taskbar_top_work_area, gfx::Rect(), |
| 63 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL); | 66 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL, |
| 67 gfx::Rect()); |
| 64 EXPECT_EQ(gfx::Rect(kWindowTilePixels, | 68 EXPECT_EQ(gfx::Rect(kWindowTilePixels, |
| 65 taskbar_top_work_area.y() + kWindowTilePixels, | 69 taskbar_top_work_area.y() + kWindowTilePixels, |
| 66 1024 - kWindowTilePixels * 2, | 70 1024 - kWindowTilePixels * 2, |
| 67 taskbar_top_work_area.height() - kWindowTilePixels * 2), | 71 taskbar_top_work_area.height() - kWindowTilePixels * 2), |
| 68 window_bounds); | 72 window_bounds); |
| 69 } | 73 } |
| 70 | 74 |
| 71 { // 4:3 monitor case, 1280x1024 | 75 { // 4:3 monitor case, 1280x1024 |
| 72 gfx::Rect window_bounds; | 76 gfx::Rect window_bounds; |
| 73 GetWindowBounds(twelveeighty, twelveeighty, gfx::Rect(), gfx::Rect(), | 77 GetWindowBounds(twelveeighty, twelveeighty, gfx::Rect(), gfx::Rect(), |
| 74 gfx::Rect(), DEFAULT, &window_bounds, NULL); | 78 gfx::Rect(), DEFAULT, &window_bounds, NULL, gfx::Rect()); |
| 75 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, | 79 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, |
| 76 1050, | 80 1050, |
| 77 1024 - kWindowTilePixels * 2), | 81 1024 - kWindowTilePixels * 2), |
| 78 window_bounds); | 82 window_bounds); |
| 79 } | 83 } |
| 80 | 84 |
| 81 { // 4:3 monitor case, 1600x1200 | 85 { // 4:3 monitor case, 1600x1200 |
| 82 gfx::Rect window_bounds; | 86 gfx::Rect window_bounds; |
| 83 GetWindowBounds(sixteenhundred, sixteenhundred, gfx::Rect(), gfx::Rect(), | 87 GetWindowBounds(sixteenhundred, sixteenhundred, gfx::Rect(), gfx::Rect(), |
| 84 gfx::Rect(), DEFAULT, &window_bounds, NULL); | 88 gfx::Rect(), DEFAULT, &window_bounds, NULL, gfx::Rect()); |
| 85 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, | 89 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, |
| 86 1050, | 90 1050, |
| 87 1200 - kWindowTilePixels * 2), | 91 1200 - kWindowTilePixels * 2), |
| 88 window_bounds); | 92 window_bounds); |
| 89 } | 93 } |
| 90 | 94 |
| 91 { // 16:10 monitor case, 1680x1050 | 95 { // 16:10 monitor case, 1680x1050 |
| 92 gfx::Rect window_bounds; | 96 gfx::Rect window_bounds; |
| 93 GetWindowBounds(sixteeneighty, sixteeneighty, gfx::Rect(), gfx::Rect(), | 97 GetWindowBounds(sixteeneighty, sixteeneighty, gfx::Rect(), gfx::Rect(), |
| 94 gfx::Rect(), DEFAULT, &window_bounds, NULL); | 98 gfx::Rect(), DEFAULT, &window_bounds, NULL, gfx::Rect()); |
| 95 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, | 99 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, |
| 96 840 - static_cast<int>(kWindowTilePixels * 1.5), | 100 840 - static_cast<int>(kWindowTilePixels * 1.5), |
| 97 1050 - kWindowTilePixels * 2), | 101 1050 - kWindowTilePixels * 2), |
| 98 window_bounds); | 102 window_bounds); |
| 99 } | 103 } |
| 100 | 104 |
| 101 { // 16:10 monitor case, 1920x1200 | 105 { // 16:10 monitor case, 1920x1200 |
| 102 gfx::Rect window_bounds; | 106 gfx::Rect window_bounds; |
| 103 GetWindowBounds(nineteentwenty, nineteentwenty, gfx::Rect(), gfx::Rect(), | 107 GetWindowBounds(nineteentwenty, nineteentwenty, gfx::Rect(), gfx::Rect(), |
| 104 gfx::Rect(), DEFAULT, &window_bounds, NULL); | 108 gfx::Rect(), DEFAULT, &window_bounds, NULL, gfx::Rect()); |
| 105 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, | 109 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, |
| 106 960 - static_cast<int>(kWindowTilePixels * 1.5), | 110 960 - static_cast<int>(kWindowTilePixels * 1.5), |
| 107 1200 - kWindowTilePixels * 2), | 111 1200 - kWindowTilePixels * 2), |
| 108 window_bounds); | 112 window_bounds); |
| 109 } | 113 } |
| 110 } | 114 } |
| 111 | 115 |
| 112 // Test that the next opened window is positioned appropriately given the | 116 // Test that the next opened window is positioned appropriately given the |
| 113 // bounds of an existing window of the same type. | 117 // bounds of an existing window of the same type. |
| 114 TEST(WindowSizerTest, LastWindowBoundsCase) { | 118 TEST(WindowSizerTest, LastWindowBoundsCase) { |
| 115 { // normal, in the middle of the screen somewhere. | 119 { // normal, in the middle of the screen somewhere. |
| 116 gfx::Rect window_bounds; | 120 gfx::Rect window_bounds; |
| 117 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 121 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 118 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400), | 122 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400), |
| 119 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL); | 123 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL, |
| 124 gfx::Rect()); |
| 120 EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2, | 125 EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2, |
| 121 kWindowTilePixels * 2, 500, 400), window_bounds); | 126 kWindowTilePixels * 2, 500, 400), window_bounds); |
| 122 } | 127 } |
| 123 | 128 |
| 124 { // taskbar on top. | 129 { // taskbar on top. |
| 125 gfx::Rect window_bounds; | 130 gfx::Rect window_bounds; |
| 126 GetWindowBounds(tentwentyfour, taskbar_top_work_area, gfx::Rect(), | 131 GetWindowBounds(tentwentyfour, taskbar_top_work_area, gfx::Rect(), |
| 127 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400), | 132 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400), |
| 128 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL); | 133 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL, |
| 134 gfx::Rect()); |
| 129 EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2, | 135 EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2, |
| 130 std::max(kWindowTilePixels * 2, | 136 std::max(kWindowTilePixels * 2, |
| 131 34 /* toolbar height */), | 137 34 /* toolbar height */), |
| 132 500, 400), window_bounds); | 138 500, 400), window_bounds); |
| 133 } | 139 } |
| 134 | 140 |
| 135 { // Too small to satisify the minimum visibility condition. | 141 { // Too small to satisify the minimum visibility condition. |
| 136 gfx::Rect window_bounds; | 142 gfx::Rect window_bounds; |
| 137 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 143 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 138 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 29, 29), | 144 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 29, 29), |
| 139 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL); | 145 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL, |
| 146 gfx::Rect()); |
| 140 EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2, | 147 EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2, |
| 141 kWindowTilePixels * 2, | 148 kWindowTilePixels * 2, |
| 142 30 /* not 29 */, | 149 30 /* not 29 */, |
| 143 30 /* not 29 */), | 150 30 /* not 29 */), |
| 144 window_bounds); | 151 window_bounds); |
| 145 } | 152 } |
| 146 | 153 |
| 147 | 154 |
| 148 { // Normal. | 155 { // Normal. |
| 149 gfx::Rect window_bounds; | 156 gfx::Rect window_bounds; |
| 150 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 157 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 151 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400), | 158 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400), |
| 152 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL); | 159 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL, |
| 160 gfx::Rect()); |
| 153 EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2, | 161 EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2, |
| 154 kWindowTilePixels * 2, 500, 400), window_bounds); | 162 kWindowTilePixels * 2, 500, 400), window_bounds); |
| 155 } | 163 } |
| 156 } | 164 } |
| 157 | 165 |
| 158 // Test that the window opened is sized appropriately given persisted sizes. | 166 // Test that the window opened is sized appropriately given persisted sizes. |
| 159 TEST(WindowSizerTest, PersistedBoundsCase) { | 167 TEST(WindowSizerTest, PersistedBoundsCase) { |
| 160 { // normal, in the middle of the screen somewhere. | 168 { // normal, in the middle of the screen somewhere. |
| 161 gfx::Rect initial_bounds(kWindowTilePixels, kWindowTilePixels, 500, 400); | 169 gfx::Rect initial_bounds(kWindowTilePixels, kWindowTilePixels, 500, 400); |
| 162 | 170 |
| 163 gfx::Rect window_bounds; | 171 gfx::Rect window_bounds; |
| 164 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), initial_bounds, | 172 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), initial_bounds, |
| 165 gfx::Rect(), PERSISTED, &window_bounds, NULL); | 173 gfx::Rect(), PERSISTED, &window_bounds, NULL, gfx::Rect()); |
| 166 EXPECT_EQ(initial_bounds, window_bounds); | 174 EXPECT_EQ(initial_bounds, window_bounds); |
| 167 } | 175 } |
| 168 | 176 |
| 169 { // Normal. | 177 { // Normal. |
| 170 gfx::Rect initial_bounds(0, 0, 1024, 768); | 178 gfx::Rect initial_bounds(0, 0, 1024, 768); |
| 171 | 179 |
| 172 gfx::Rect window_bounds; | 180 gfx::Rect window_bounds; |
| 173 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), initial_bounds, | 181 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), initial_bounds, |
| 174 gfx::Rect(), PERSISTED, &window_bounds, NULL); | 182 gfx::Rect(), PERSISTED, &window_bounds, NULL, gfx::Rect()); |
| 175 EXPECT_EQ(initial_bounds, window_bounds); | 183 EXPECT_EQ(initial_bounds, window_bounds); |
| 176 } | 184 } |
| 177 | 185 |
| 178 { // normal, on non-primary monitor in negative coords. | 186 { // normal, on non-primary monitor in negative coords. |
| 179 gfx::Rect initial_bounds(-600, 10, 500, 400); | 187 gfx::Rect initial_bounds(-600, 10, 500, 400); |
| 180 | 188 |
| 181 gfx::Rect window_bounds; | 189 gfx::Rect window_bounds; |
| 182 GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary, | 190 GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary, |
| 183 initial_bounds, gfx::Rect(), PERSISTED, &window_bounds, | 191 initial_bounds, gfx::Rect(), PERSISTED, &window_bounds, |
| 184 NULL); | 192 NULL, gfx::Rect()); |
| 185 EXPECT_EQ(initial_bounds, window_bounds); | 193 EXPECT_EQ(initial_bounds, window_bounds); |
| 186 } | 194 } |
| 187 | 195 |
| 188 { // normal, on non-primary monitor in negative coords. | 196 { // normal, on non-primary monitor in negative coords. |
| 189 gfx::Rect initial_bounds(-1024, 0, 1024, 768); | 197 gfx::Rect initial_bounds(-1024, 0, 1024, 768); |
| 190 | 198 |
| 191 gfx::Rect window_bounds; | 199 gfx::Rect window_bounds; |
| 192 GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary, | 200 GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary, |
| 193 initial_bounds, gfx::Rect(), PERSISTED, &window_bounds, | 201 initial_bounds, gfx::Rect(), PERSISTED, &window_bounds, |
| 194 NULL); | 202 NULL, gfx::Rect()); |
| 195 EXPECT_EQ(initial_bounds, window_bounds); | 203 EXPECT_EQ(initial_bounds, window_bounds); |
| 196 } | 204 } |
| 197 | 205 |
| 198 { // Non-primary monitor resoultion has changed, but the monitor still | 206 { // Non-primary monitor resoultion has changed, but the monitor still |
| 199 // completely contains the window. | 207 // completely contains the window. |
| 200 | 208 |
| 201 gfx::Rect initial_bounds(1074, 50, 600, 500); | 209 gfx::Rect initial_bounds(1074, 50, 600, 500); |
| 202 | 210 |
| 203 gfx::Rect window_bounds; | 211 gfx::Rect window_bounds; |
| 204 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600), | 212 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600), |
| 205 initial_bounds, right_nonprimary, PERSISTED, | 213 initial_bounds, right_nonprimary, PERSISTED, |
| 206 &window_bounds, NULL); | 214 &window_bounds, NULL, gfx::Rect()); |
| 207 EXPECT_EQ(initial_bounds, window_bounds); | 215 EXPECT_EQ(initial_bounds, window_bounds); |
| 208 } | 216 } |
| 209 | 217 |
| 210 { // Non-primary monitor resoultion has changed, and the window is partially | 218 { // Non-primary monitor resoultion has changed, and the window is partially |
| 211 // off-screen. | 219 // off-screen. |
| 212 | 220 |
| 213 gfx::Rect initial_bounds(1274, 50, 600, 500); | 221 gfx::Rect initial_bounds(1274, 50, 600, 500); |
| 214 | 222 |
| 215 gfx::Rect window_bounds; | 223 gfx::Rect window_bounds; |
| 216 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600), | 224 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600), |
| 217 initial_bounds, right_nonprimary, PERSISTED, | 225 initial_bounds, right_nonprimary, PERSISTED, |
| 218 &window_bounds, NULL); | 226 &window_bounds, NULL, gfx::Rect()); |
| 219 EXPECT_EQ(gfx::Rect(1224, 50, 600, 500), window_bounds); | 227 EXPECT_EQ(gfx::Rect(1224, 50, 600, 500), window_bounds); |
| 220 } | 228 } |
| 221 | 229 |
| 222 { // Non-primary monitor resoultion has changed, and the window is now too | 230 { // Non-primary monitor resoultion has changed, and the window is now too |
| 223 // large for the monitor. | 231 // large for the monitor. |
| 224 | 232 |
| 225 gfx::Rect initial_bounds(1274, 50, 900, 700); | 233 gfx::Rect initial_bounds(1274, 50, 900, 700); |
| 226 | 234 |
| 227 gfx::Rect window_bounds; | 235 gfx::Rect window_bounds; |
| 228 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600), | 236 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600), |
| 229 initial_bounds, right_nonprimary, PERSISTED, | 237 initial_bounds, right_nonprimary, PERSISTED, |
| 230 &window_bounds, NULL); | 238 &window_bounds, NULL, gfx::Rect()); |
| 231 EXPECT_EQ(gfx::Rect(1024, 0, 800, 600), window_bounds); | 239 EXPECT_EQ(gfx::Rect(1024, 0, 800, 600), window_bounds); |
| 232 } | 240 } |
| 233 | 241 |
| 234 { // width and height too small | 242 { // width and height too small |
| 235 gfx::Rect window_bounds; | 243 gfx::Rect window_bounds; |
| 236 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 244 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 237 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 29, 29), | 245 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 29, 29), |
| 238 gfx::Rect(), PERSISTED, &window_bounds, NULL); | 246 gfx::Rect(), PERSISTED, &window_bounds, NULL, gfx::Rect()); |
| 239 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, | 247 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, |
| 240 30 /* not 29 */, 30 /* not 29 */), | 248 30 /* not 29 */, 30 /* not 29 */), |
| 241 window_bounds); | 249 window_bounds); |
| 242 } | 250 } |
| 243 | 251 |
| 244 #if defined(OS_MACOSX) | 252 #if defined(OS_MACOSX) |
| 245 { // Saved state is too tall to possibly be resized. Mac resizers | 253 { // Saved state is too tall to possibly be resized. Mac resizers |
| 246 // are at the bottom of the window, and no piece of a window can | 254 // are at the bottom of the window, and no piece of a window can |
| 247 // be moved higher than the menubar. (Perhaps the user changed | 255 // be moved higher than the menubar. (Perhaps the user changed |
| 248 // resolution to something smaller before relaunching Chrome?) | 256 // resolution to something smaller before relaunching Chrome?) |
| 249 gfx::Rect window_bounds; | 257 gfx::Rect window_bounds; |
| 250 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 258 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 251 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 30, 5000), | 259 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 30, 5000), |
| 252 gfx::Rect(), PERSISTED, &window_bounds, NULL); | 260 gfx::Rect(), PERSISTED, &window_bounds, NULL, gfx::Rect()); |
| 253 EXPECT_EQ(tentwentyfour.height(), window_bounds.height()); | 261 EXPECT_EQ(tentwentyfour.height(), window_bounds.height()); |
| 254 } | 262 } |
| 255 #endif // defined(OS_MACOSX) | 263 #endif // defined(OS_MACOSX) |
| 256 } | 264 } |
| 257 | 265 |
| 258 ////////////////////////////////////////////////////////////////////////////// | 266 ////////////////////////////////////////////////////////////////////////////// |
| 259 // The following unittests have different results on Mac/non-Mac because we | 267 // The following unittests have different results on Mac/non-Mac because we |
| 260 // reposition windows aggressively on Mac. The *WithAggressiveReposition tests | 268 // reposition windows aggressively on Mac. The *WithAggressiveReposition tests |
| 261 // are run on Mac, and the *WithNonAggressiveRepositioning tests are run on | 269 // are run on Mac, and the *WithNonAggressiveRepositioning tests are run on |
| 262 // other platforms. | 270 // other platforms. |
| 263 | 271 |
| 264 #if defined(OS_MACOSX) | 272 #if defined(OS_MACOSX) |
| 265 TEST(WindowSizerTest, LastWindowOffscreenWithAggressiveRepositioning) { | 273 TEST(WindowSizerTest, LastWindowOffscreenWithAggressiveRepositioning) { |
| 266 { // taskbar on left. The new window overlaps slightly with the taskbar, so | 274 { // taskbar on left. The new window overlaps slightly with the taskbar, so |
| 267 // it is moved to be flush with the left edge of the work area. | 275 // it is moved to be flush with the left edge of the work area. |
| 268 gfx::Rect window_bounds; | 276 gfx::Rect window_bounds; |
| 269 GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(), | 277 GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(), |
| 270 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400), | 278 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400), |
| 271 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL); | 279 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL, |
| 280 gfx::Rect()); |
| 272 EXPECT_EQ(gfx::Rect(taskbar_left_work_area.x(), | 281 EXPECT_EQ(gfx::Rect(taskbar_left_work_area.x(), |
| 273 kWindowTilePixels * 2, 500, 400), window_bounds); | 282 kWindowTilePixels * 2, 500, 400), window_bounds); |
| 274 } | 283 } |
| 275 | 284 |
| 276 { // offset would put the new window offscreen at the bottom | 285 { // offset would put the new window offscreen at the bottom |
| 277 gfx::Rect window_bounds; | 286 gfx::Rect window_bounds; |
| 278 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 287 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 279 gfx::Rect(10, 729, 500, 400), gfx::Rect(), LAST_ACTIVE, | 288 gfx::Rect(10, 729, 500, 400), gfx::Rect(), LAST_ACTIVE, |
| 280 &window_bounds, NULL); | 289 &window_bounds, NULL, gfx::Rect()); |
| 281 EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, | 290 EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, |
| 282 0 /* not 729 + kWindowTilePixels */, | 291 0 /* not 729 + kWindowTilePixels */, |
| 283 500, 400), | 292 500, 400), |
| 284 window_bounds); | 293 window_bounds); |
| 285 } | 294 } |
| 286 | 295 |
| 287 { // offset would put the new window offscreen at the right | 296 { // offset would put the new window offscreen at the right |
| 288 gfx::Rect window_bounds; | 297 gfx::Rect window_bounds; |
| 289 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 298 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 290 gfx::Rect(985, 10, 500, 400), gfx::Rect(), LAST_ACTIVE, | 299 gfx::Rect(985, 10, 500, 400), gfx::Rect(), LAST_ACTIVE, |
| 291 &window_bounds, NULL); | 300 &window_bounds, NULL, gfx::Rect()); |
| 292 EXPECT_EQ(gfx::Rect(0 /* not 985 + kWindowTilePixels*/, | 301 EXPECT_EQ(gfx::Rect(0 /* not 985 + kWindowTilePixels*/, |
| 293 10 + kWindowTilePixels, | 302 10 + kWindowTilePixels, |
| 294 500, 400), | 303 500, 400), |
| 295 window_bounds); | 304 window_bounds); |
| 296 } | 305 } |
| 297 | 306 |
| 298 { // offset would put the new window offscreen at the bottom right | 307 { // offset would put the new window offscreen at the bottom right |
| 299 gfx::Rect window_bounds; | 308 gfx::Rect window_bounds; |
| 300 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 309 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 301 gfx::Rect(985, 729, 500, 400), gfx::Rect(), LAST_ACTIVE, | 310 gfx::Rect(985, 729, 500, 400), gfx::Rect(), LAST_ACTIVE, |
| 302 &window_bounds, NULL); | 311 &window_bounds, NULL, gfx::Rect()); |
| 303 EXPECT_EQ(gfx::Rect(0 /* not 985 + kWindowTilePixels*/, | 312 EXPECT_EQ(gfx::Rect(0 /* not 985 + kWindowTilePixels*/, |
| 304 0 /* not 729 + kWindowTilePixels*/, | 313 0 /* not 729 + kWindowTilePixels*/, |
| 305 500, 400), | 314 500, 400), |
| 306 window_bounds); | 315 window_bounds); |
| 307 } | 316 } |
| 308 } | 317 } |
| 309 | 318 |
| 310 TEST(WindowSizerTest, PersistedWindowOffscreenWithAggressiveRepositioning) { | 319 TEST(WindowSizerTest, PersistedWindowOffscreenWithAggressiveRepositioning) { |
| 311 { // off the left | 320 { // off the left |
| 312 gfx::Rect window_bounds; | 321 gfx::Rect window_bounds; |
| 313 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 322 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 314 gfx::Rect(-471, 50, 500, 400), gfx::Rect(), PERSISTED, | 323 gfx::Rect(-471, 50, 500, 400), gfx::Rect(), PERSISTED, |
| 315 &window_bounds, NULL); | 324 &window_bounds, NULL, gfx::Rect()); |
| 316 EXPECT_EQ(gfx::Rect(0 /* not -471 */, 50, 500, 400), window_bounds); | 325 EXPECT_EQ(gfx::Rect(0 /* not -471 */, 50, 500, 400), window_bounds); |
| 317 } | 326 } |
| 318 | 327 |
| 319 { // off the top | 328 { // off the top |
| 320 gfx::Rect window_bounds; | 329 gfx::Rect window_bounds; |
| 321 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 330 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 322 gfx::Rect(50, -370, 500, 400), gfx::Rect(), PERSISTED, | 331 gfx::Rect(50, -370, 500, 400), gfx::Rect(), PERSISTED, |
| 323 &window_bounds, NULL); | 332 &window_bounds, NULL, gfx::Rect()); |
| 324 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); | 333 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); |
| 325 } | 334 } |
| 326 | 335 |
| 327 { // off the right | 336 { // off the right |
| 328 gfx::Rect window_bounds; | 337 gfx::Rect window_bounds; |
| 329 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 338 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 330 gfx::Rect(995, 50, 500, 400), gfx::Rect(), PERSISTED, | 339 gfx::Rect(995, 50, 500, 400), gfx::Rect(), PERSISTED, |
| 331 &window_bounds, NULL); | 340 &window_bounds, NULL, gfx::Rect()); |
| 332 EXPECT_EQ(gfx::Rect(0 /* not 995 */, 50, 500, 400), window_bounds); | 341 EXPECT_EQ(gfx::Rect(0 /* not 995 */, 50, 500, 400), window_bounds); |
| 333 } | 342 } |
| 334 | 343 |
| 335 { // off the bottom | 344 { // off the bottom |
| 336 gfx::Rect window_bounds; | 345 gfx::Rect window_bounds; |
| 337 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 346 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 338 gfx::Rect(50, 739, 500, 400), gfx::Rect(), PERSISTED, | 347 gfx::Rect(50, 739, 500, 400), gfx::Rect(), PERSISTED, |
| 339 &window_bounds, NULL); | 348 &window_bounds, NULL, gfx::Rect()); |
| 340 EXPECT_EQ(gfx::Rect(50, 0 /* not 739 */, 500, 400), window_bounds); | 349 EXPECT_EQ(gfx::Rect(50, 0 /* not 739 */, 500, 400), window_bounds); |
| 341 } | 350 } |
| 342 | 351 |
| 343 { // off the topleft | 352 { // off the topleft |
| 344 gfx::Rect window_bounds; | 353 gfx::Rect window_bounds; |
| 345 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 354 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 346 gfx::Rect(-471, -371, 500, 400), gfx::Rect(), PERSISTED, | 355 gfx::Rect(-471, -371, 500, 400), gfx::Rect(), PERSISTED, |
| 347 &window_bounds, NULL); | 356 &window_bounds, NULL, gfx::Rect()); |
| 348 EXPECT_EQ(gfx::Rect(0 /* not -471 */, 0 /* not -371 */, 500, 400), | 357 EXPECT_EQ(gfx::Rect(0 /* not -471 */, 0 /* not -371 */, 500, 400), |
| 349 window_bounds); | 358 window_bounds); |
| 350 } | 359 } |
| 351 | 360 |
| 352 { // off the topright | 361 { // off the topright |
| 353 gfx::Rect window_bounds; | 362 gfx::Rect window_bounds; |
| 354 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 363 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 355 gfx::Rect(995, -371, 500, 400), gfx::Rect(), PERSISTED, | 364 gfx::Rect(995, -371, 500, 400), gfx::Rect(), PERSISTED, |
| 356 &window_bounds, NULL); | 365 &window_bounds, NULL, gfx::Rect()); |
| 357 EXPECT_EQ(gfx::Rect(0 /* not 995 */, 0 /* not -371 */, 500, 400), | 366 EXPECT_EQ(gfx::Rect(0 /* not 995 */, 0 /* not -371 */, 500, 400), |
| 358 window_bounds); | 367 window_bounds); |
| 359 } | 368 } |
| 360 | 369 |
| 361 { // off the bottomleft | 370 { // off the bottomleft |
| 362 gfx::Rect window_bounds; | 371 gfx::Rect window_bounds; |
| 363 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 372 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 364 gfx::Rect(-471, 739, 500, 400), gfx::Rect(), PERSISTED, | 373 gfx::Rect(-471, 739, 500, 400), gfx::Rect(), PERSISTED, |
| 365 &window_bounds, NULL); | 374 &window_bounds, NULL, gfx::Rect()); |
| 366 EXPECT_EQ(gfx::Rect(0 /* not -471 */, 0 /* not 739 */, 500, 400), | 375 EXPECT_EQ(gfx::Rect(0 /* not -471 */, 0 /* not 739 */, 500, 400), |
| 367 window_bounds); | 376 window_bounds); |
| 368 } | 377 } |
| 369 | 378 |
| 370 { // off the bottomright | 379 { // off the bottomright |
| 371 gfx::Rect window_bounds; | 380 gfx::Rect window_bounds; |
| 372 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 381 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 373 gfx::Rect(995, 739, 500, 400), gfx::Rect(), PERSISTED, | 382 gfx::Rect(995, 739, 500, 400), gfx::Rect(), PERSISTED, |
| 374 &window_bounds, NULL); | 383 &window_bounds, NULL, gfx::Rect()); |
| 375 EXPECT_EQ(gfx::Rect(0 /* not 995 */, 0 /* not 739 */, 500, 400), | 384 EXPECT_EQ(gfx::Rect(0 /* not 995 */, 0 /* not 739 */, 500, 400), |
| 376 window_bounds); | 385 window_bounds); |
| 377 } | 386 } |
| 378 | 387 |
| 379 { // entirely off left | 388 { // entirely off left |
| 380 gfx::Rect window_bounds; | 389 gfx::Rect window_bounds; |
| 381 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 390 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 382 gfx::Rect(-700, 50, 500, 400), gfx::Rect(), PERSISTED, | 391 gfx::Rect(-700, 50, 500, 400), gfx::Rect(), PERSISTED, |
| 383 &window_bounds, NULL); | 392 &window_bounds, NULL, gfx::Rect()); |
| 384 EXPECT_EQ(gfx::Rect(0 /* not -700 */, 50, 500, 400), window_bounds); | 393 EXPECT_EQ(gfx::Rect(0 /* not -700 */, 50, 500, 400), window_bounds); |
| 385 } | 394 } |
| 386 | 395 |
| 387 { // entirely off left (monitor was detached since last run) | 396 { // entirely off left (monitor was detached since last run) |
| 388 gfx::Rect window_bounds; | 397 gfx::Rect window_bounds; |
| 389 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 398 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 390 gfx::Rect(-700, 50, 500, 400), left_nonprimary, | 399 gfx::Rect(-700, 50, 500, 400), left_nonprimary, |
| 391 PERSISTED, &window_bounds, NULL); | 400 PERSISTED, &window_bounds, NULL, gfx::Rect()); |
| 392 EXPECT_EQ(gfx::Rect(0, 50, 500, 400), window_bounds); | 401 EXPECT_EQ(gfx::Rect(0, 50, 500, 400), window_bounds); |
| 393 } | 402 } |
| 394 | 403 |
| 395 { // entirely off top | 404 { // entirely off top |
| 396 gfx::Rect window_bounds; | 405 gfx::Rect window_bounds; |
| 397 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 406 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 398 gfx::Rect(50, -500, 500, 400), gfx::Rect(), PERSISTED, | 407 gfx::Rect(50, -500, 500, 400), gfx::Rect(), PERSISTED, |
| 399 &window_bounds, NULL); | 408 &window_bounds, NULL, gfx::Rect()); |
| 400 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); | 409 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); |
| 401 } | 410 } |
| 402 | 411 |
| 403 { // entirely off top (monitor was detached since last run) | 412 { // entirely off top (monitor was detached since last run) |
| 404 gfx::Rect window_bounds; | 413 gfx::Rect window_bounds; |
| 405 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 414 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 406 gfx::Rect(50, -500, 500, 400), top_nonprimary, PERSISTED, | 415 gfx::Rect(50, -500, 500, 400), top_nonprimary, PERSISTED, |
| 407 &window_bounds, NULL); | 416 &window_bounds, NULL, gfx::Rect()); |
| 408 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); | 417 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); |
| 409 } | 418 } |
| 410 | 419 |
| 411 { // entirely off right | 420 { // entirely off right |
| 412 gfx::Rect window_bounds; | 421 gfx::Rect window_bounds; |
| 413 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 422 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 414 gfx::Rect(1200, 50, 500, 400), gfx::Rect(), PERSISTED, | 423 gfx::Rect(1200, 50, 500, 400), gfx::Rect(), PERSISTED, |
| 415 &window_bounds, NULL); | 424 &window_bounds, NULL, gfx::Rect()); |
| 416 EXPECT_EQ(gfx::Rect(0 /* not 1200 */, 50, 500, 400), window_bounds); | 425 EXPECT_EQ(gfx::Rect(0 /* not 1200 */, 50, 500, 400), window_bounds); |
| 417 } | 426 } |
| 418 | 427 |
| 419 { // entirely off right (monitor was detached since last run) | 428 { // entirely off right (monitor was detached since last run) |
| 420 gfx::Rect window_bounds; | 429 gfx::Rect window_bounds; |
| 421 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 430 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 422 gfx::Rect(1200, 50, 500, 400), right_nonprimary, PERSISTED, | 431 gfx::Rect(1200, 50, 500, 400), right_nonprimary, PERSISTED, |
| 423 &window_bounds, NULL); | 432 &window_bounds, NULL, gfx::Rect()); |
| 424 EXPECT_EQ(gfx::Rect(524 /* not 1200 */, 50, 500, 400), window_bounds); | 433 EXPECT_EQ(gfx::Rect(524 /* not 1200 */, 50, 500, 400), window_bounds); |
| 425 } | 434 } |
| 426 | 435 |
| 427 { // entirely off bottom | 436 { // entirely off bottom |
| 428 gfx::Rect window_bounds; | 437 gfx::Rect window_bounds; |
| 429 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 438 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 430 gfx::Rect(50, 800, 500, 400), gfx::Rect(), PERSISTED, | 439 gfx::Rect(50, 800, 500, 400), gfx::Rect(), PERSISTED, |
| 431 &window_bounds, NULL); | 440 &window_bounds, NULL, gfx::Rect()); |
| 432 EXPECT_EQ(gfx::Rect(50, 0 /* not 800 */, 500, 400), window_bounds); | 441 EXPECT_EQ(gfx::Rect(50, 0 /* not 800 */, 500, 400), window_bounds); |
| 433 } | 442 } |
| 434 | 443 |
| 435 { // entirely off bottom (monitor was detached since last run) | 444 { // entirely off bottom (monitor was detached since last run) |
| 436 gfx::Rect window_bounds; | 445 gfx::Rect window_bounds; |
| 437 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 446 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 438 gfx::Rect(50, 800, 500, 400), bottom_nonprimary, | 447 gfx::Rect(50, 800, 500, 400), bottom_nonprimary, |
| 439 PERSISTED, &window_bounds, NULL); | 448 PERSISTED, &window_bounds, NULL, gfx::Rect()); |
| 440 EXPECT_EQ(gfx::Rect(50, 368 /* not 800 */, 500, 400), window_bounds); | 449 EXPECT_EQ(gfx::Rect(50, 368 /* not 800 */, 500, 400), window_bounds); |
| 441 } | 450 } |
| 442 | 451 |
| 443 { // wider than the screen. off both the left and right | 452 { // wider than the screen. off both the left and right |
| 444 gfx::Rect window_bounds; | 453 gfx::Rect window_bounds; |
| 445 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 454 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 446 gfx::Rect(-100, 50, 2000, 400), gfx::Rect(), PERSISTED, | 455 gfx::Rect(-100, 50, 2000, 400), gfx::Rect(), PERSISTED, |
| 447 &window_bounds, NULL); | 456 &window_bounds, NULL, gfx::Rect()); |
| 448 EXPECT_EQ(gfx::Rect(0 /* not -100 */, 50, 2000, 400), window_bounds); | 457 EXPECT_EQ(gfx::Rect(0 /* not -100 */, 50, 2000, 400), window_bounds); |
| 449 } | 458 } |
| 450 } | 459 } |
| 451 #else | 460 #else |
| 452 TEST(WindowSizerTest, LastWindowOffscreenWithNonAggressiveRepositioning) { | 461 TEST(WindowSizerTest, LastWindowOffscreenWithNonAggressiveRepositioning) { |
| 453 { // taskbar on left. | 462 { // taskbar on left. |
| 454 gfx::Rect window_bounds; | 463 gfx::Rect window_bounds; |
| 455 GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(), | 464 GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(), |
| 456 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400), | 465 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400), |
| 457 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL); | 466 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL, |
| 467 gfx::Rect()); |
| 458 EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2, | 468 EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2, |
| 459 kWindowTilePixels * 2, 500, 400), window_bounds); | 469 kWindowTilePixels * 2, 500, 400), window_bounds); |
| 460 } | 470 } |
| 461 | 471 |
| 462 // Linux does not tile windows, so tile adjustment tests don't make sense. | 472 // Linux does not tile windows, so tile adjustment tests don't make sense. |
| 463 #if !defined(OS_POSIX) || defined(OS_MACOSX) | 473 #if !defined(OS_POSIX) || defined(OS_MACOSX) |
| 464 { // offset would put the new window offscreen at the bottom but the minimum | 474 { // offset would put the new window offscreen at the bottom but the minimum |
| 465 // visibility condition is barely satisfied without relocation. | 475 // visibility condition is barely satisfied without relocation. |
| 466 gfx::Rect window_bounds; | 476 gfx::Rect window_bounds; |
| 467 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 477 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 468 gfx::Rect(10, 728, 500, 400), gfx::Rect(), LAST_ACTIVE, | 478 gfx::Rect(10, 728, 500, 400), gfx::Rect(), LAST_ACTIVE, |
| 469 &window_bounds, NULL); | 479 &window_bounds, NULL, gfx::Rect()); |
| 470 EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 738, | 480 EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 738, |
| 471 500, 400), window_bounds); | 481 500, 400), window_bounds); |
| 472 } | 482 } |
| 473 | 483 |
| 474 { // offset would put the new window offscreen at the bottom and the minimum | 484 { // offset would put the new window offscreen at the bottom and the minimum |
| 475 // visibility condition is satisified by relocation. | 485 // visibility condition is satisified by relocation. |
| 476 gfx::Rect window_bounds; | 486 gfx::Rect window_bounds; |
| 477 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 487 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 478 gfx::Rect(10, 729, 500, 400), gfx::Rect(), LAST_ACTIVE, | 488 gfx::Rect(10, 729, 500, 400), gfx::Rect(), LAST_ACTIVE, |
| 479 &window_bounds, NULL); | 489 &window_bounds, NULL, gfx::Rect()); |
| 480 EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 738 /* not 739 */, 500, 400), | 490 EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 738 /* not 739 */, 500, 400), |
| 481 window_bounds); | 491 window_bounds); |
| 482 } | 492 } |
| 483 | 493 |
| 484 { // offset would put the new window offscreen at the right but the minimum | 494 { // offset would put the new window offscreen at the right but the minimum |
| 485 // visibility condition is barely satisfied without relocation. | 495 // visibility condition is barely satisfied without relocation. |
| 486 gfx::Rect window_bounds; | 496 gfx::Rect window_bounds; |
| 487 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 497 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 488 gfx::Rect(984, 10, 500, 400), gfx::Rect(), LAST_ACTIVE, | 498 gfx::Rect(984, 10, 500, 400), gfx::Rect(), LAST_ACTIVE, |
| 489 &window_bounds, NULL); | 499 &window_bounds, NULL, gfx::Rect()); |
| 490 EXPECT_EQ(gfx::Rect(994, 10 + kWindowTilePixels, 500, 400), window_bounds); | 500 EXPECT_EQ(gfx::Rect(994, 10 + kWindowTilePixels, 500, 400), window_bounds); |
| 491 } | 501 } |
| 492 | 502 |
| 493 { // offset would put the new window offscreen at the right and the minimum | 503 { // offset would put the new window offscreen at the right and the minimum |
| 494 // visibility condition is satisified by relocation. | 504 // visibility condition is satisified by relocation. |
| 495 gfx::Rect window_bounds; | 505 gfx::Rect window_bounds; |
| 496 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 506 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 497 gfx::Rect(985, 10, 500, 400), gfx::Rect(), LAST_ACTIVE, | 507 gfx::Rect(985, 10, 500, 400), gfx::Rect(), LAST_ACTIVE, |
| 498 &window_bounds, NULL); | 508 &window_bounds, NULL, gfx::Rect()); |
| 499 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 10 + kWindowTilePixels, | 509 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 10 + kWindowTilePixels, |
| 500 500, 400), window_bounds); | 510 500, 400), window_bounds); |
| 501 } | 511 } |
| 502 | 512 |
| 503 { // offset would put the new window offscreen at the bottom right and the | 513 { // offset would put the new window offscreen at the bottom right and the |
| 504 // minimum visibility condition is satisified by relocation. | 514 // minimum visibility condition is satisified by relocation. |
| 505 gfx::Rect window_bounds; | 515 gfx::Rect window_bounds; |
| 506 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 516 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 507 gfx::Rect(985, 729, 500, 400), gfx::Rect(), LAST_ACTIVE, | 517 gfx::Rect(985, 729, 500, 400), gfx::Rect(), LAST_ACTIVE, |
| 508 &window_bounds, NULL); | 518 &window_bounds, NULL, gfx::Rect()); |
| 509 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 738 /* not 739 */, 500, 400), | 519 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 738 /* not 739 */, 500, 400), |
| 510 window_bounds); | 520 window_bounds); |
| 511 } | 521 } |
| 512 #endif // !defined(OS_POSIX) || defined(OS_MACOSX) | 522 #endif // !defined(OS_POSIX) || defined(OS_MACOSX) |
| 513 } | 523 } |
| 514 | 524 |
| 515 TEST(WindowSizerTest, PersistedWindowOffscreenWithNonAggressiveRepositioning) { | 525 TEST(WindowSizerTest, PersistedWindowOffscreenWithNonAggressiveRepositioning) { |
| 516 { // off the left but the minimum visibility condition is barely satisfied | 526 { // off the left but the minimum visibility condition is barely satisfied |
| 517 // without relocaiton. | 527 // without relocaiton. |
| 518 gfx::Rect initial_bounds(-470, 50, 500, 400); | 528 gfx::Rect initial_bounds(-470, 50, 500, 400); |
| 519 | 529 |
| 520 gfx::Rect window_bounds; | 530 gfx::Rect window_bounds; |
| 521 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 531 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 522 initial_bounds, gfx::Rect(), PERSISTED, | 532 initial_bounds, gfx::Rect(), PERSISTED, |
| 523 &window_bounds, NULL); | 533 &window_bounds, NULL, gfx::Rect()); |
| 524 EXPECT_EQ(initial_bounds, window_bounds); | 534 EXPECT_EQ(initial_bounds, window_bounds); |
| 525 } | 535 } |
| 526 | 536 |
| 527 { // off the left and the minimum visibility condition is satisfied by | 537 { // off the left and the minimum visibility condition is satisfied by |
| 528 // relocation. | 538 // relocation. |
| 529 gfx::Rect window_bounds; | 539 gfx::Rect window_bounds; |
| 530 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 540 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 531 gfx::Rect(-471, 50, 500, 400), gfx::Rect(), PERSISTED, | 541 gfx::Rect(-471, 50, 500, 400), gfx::Rect(), PERSISTED, |
| 532 &window_bounds, NULL); | 542 &window_bounds, NULL, gfx::Rect()); |
| 533 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 50, 500, 400), window_bounds); | 543 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 50, 500, 400), window_bounds); |
| 534 } | 544 } |
| 535 | 545 |
| 536 { // off the top | 546 { // off the top |
| 537 gfx::Rect initial_bounds(50, -370, 500, 400); | 547 gfx::Rect initial_bounds(50, -370, 500, 400); |
| 538 | 548 |
| 539 gfx::Rect window_bounds; | 549 gfx::Rect window_bounds; |
| 540 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 550 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 541 gfx::Rect(50, -370, 500, 400), gfx::Rect(), PERSISTED, | 551 gfx::Rect(50, -370, 500, 400), gfx::Rect(), PERSISTED, |
| 542 &window_bounds, NULL); | 552 &window_bounds, NULL, gfx::Rect()); |
| 543 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); | 553 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); |
| 544 } | 554 } |
| 545 | 555 |
| 546 { // off the right but the minimum visibility condition is barely satisified | 556 { // off the right but the minimum visibility condition is barely satisified |
| 547 // without relocation. | 557 // without relocation. |
| 548 gfx::Rect initial_bounds(994, 50, 500, 400); | 558 gfx::Rect initial_bounds(994, 50, 500, 400); |
| 549 | 559 |
| 550 gfx::Rect window_bounds; | 560 gfx::Rect window_bounds; |
| 551 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 561 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 552 initial_bounds, gfx::Rect(), PERSISTED, | 562 initial_bounds, gfx::Rect(), PERSISTED, |
| 553 &window_bounds, NULL); | 563 &window_bounds, NULL, gfx::Rect()); |
| 554 EXPECT_EQ(initial_bounds, window_bounds); | 564 EXPECT_EQ(initial_bounds, window_bounds); |
| 555 } | 565 } |
| 556 | 566 |
| 557 { // off the right and the minimum visibility condition is satisified by | 567 { // off the right and the minimum visibility condition is satisified by |
| 558 // relocation. | 568 // relocation. |
| 559 gfx::Rect window_bounds; | 569 gfx::Rect window_bounds; |
| 560 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 570 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 561 gfx::Rect(995, 50, 500, 400), gfx::Rect(), PERSISTED, | 571 gfx::Rect(995, 50, 500, 400), gfx::Rect(), PERSISTED, |
| 562 &window_bounds, NULL); | 572 &window_bounds, NULL, gfx::Rect()); |
| 563 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 50, 500, 400), window_bounds); | 573 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 50, 500, 400), window_bounds); |
| 564 } | 574 } |
| 565 | 575 |
| 566 { // off the bottom but the minimum visibility condition is barely satisified | 576 { // off the bottom but the minimum visibility condition is barely satisified |
| 567 // without relocation. | 577 // without relocation. |
| 568 gfx::Rect initial_bounds(50, 738, 500, 400); | 578 gfx::Rect initial_bounds(50, 738, 500, 400); |
| 569 | 579 |
| 570 gfx::Rect window_bounds; | 580 gfx::Rect window_bounds; |
| 571 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 581 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 572 initial_bounds, gfx::Rect(), PERSISTED, | 582 initial_bounds, gfx::Rect(), PERSISTED, |
| 573 &window_bounds, NULL); | 583 &window_bounds, NULL, gfx::Rect()); |
| 574 EXPECT_EQ(initial_bounds, window_bounds); | 584 EXPECT_EQ(initial_bounds, window_bounds); |
| 575 } | 585 } |
| 576 | 586 |
| 577 { // off the bottom and the minimum visibility condition is satisified by | 587 { // off the bottom and the minimum visibility condition is satisified by |
| 578 // relocation. | 588 // relocation. |
| 579 gfx::Rect window_bounds; | 589 gfx::Rect window_bounds; |
| 580 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 590 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 581 gfx::Rect(50, 739, 500, 400), gfx::Rect(), PERSISTED, | 591 gfx::Rect(50, 739, 500, 400), gfx::Rect(), PERSISTED, |
| 582 &window_bounds, NULL); | 592 &window_bounds, NULL, gfx::Rect()); |
| 583 EXPECT_EQ(gfx::Rect(50, 738 /* not 739 */, 500, 400), window_bounds); | 593 EXPECT_EQ(gfx::Rect(50, 738 /* not 739 */, 500, 400), window_bounds); |
| 584 } | 594 } |
| 585 | 595 |
| 586 { // off the topleft | 596 { // off the topleft |
| 587 gfx::Rect window_bounds; | 597 gfx::Rect window_bounds; |
| 588 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 598 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 589 gfx::Rect(-471, -371, 500, 400), gfx::Rect(), PERSISTED, | 599 gfx::Rect(-471, -371, 500, 400), gfx::Rect(), PERSISTED, |
| 590 &window_bounds, NULL); | 600 &window_bounds, NULL, gfx::Rect()); |
| 591 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 0, 500, 400), | 601 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 0, 500, 400), |
| 592 window_bounds); | 602 window_bounds); |
| 593 } | 603 } |
| 594 | 604 |
| 595 { // off the topright and the minimum visibility condition is satisified by | 605 { // off the topright and the minimum visibility condition is satisified by |
| 596 // relocation. | 606 // relocation. |
| 597 gfx::Rect window_bounds; | 607 gfx::Rect window_bounds; |
| 598 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 608 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 599 gfx::Rect(995, -371, 500, 400), gfx::Rect(), PERSISTED, | 609 gfx::Rect(995, -371, 500, 400), gfx::Rect(), PERSISTED, |
| 600 &window_bounds, NULL); | 610 &window_bounds, NULL, gfx::Rect()); |
| 601 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 0, 500, 400), | 611 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 0, 500, 400), |
| 602 window_bounds); | 612 window_bounds); |
| 603 } | 613 } |
| 604 | 614 |
| 605 { // off the bottomleft and the minimum visibility condition is satisified by | 615 { // off the bottomleft and the minimum visibility condition is satisified by |
| 606 // relocation. | 616 // relocation. |
| 607 gfx::Rect window_bounds; | 617 gfx::Rect window_bounds; |
| 608 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 618 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 609 gfx::Rect(-471, 739, 500, 400), gfx::Rect(), PERSISTED, | 619 gfx::Rect(-471, 739, 500, 400), gfx::Rect(), PERSISTED, |
| 610 &window_bounds, NULL); | 620 &window_bounds, NULL, gfx::Rect()); |
| 611 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 738 /* not 739 */, 500, 400), | 621 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 738 /* not 739 */, 500, 400), |
| 612 window_bounds); | 622 window_bounds); |
| 613 } | 623 } |
| 614 | 624 |
| 615 { // off the bottomright and the minimum visibility condition is satisified by | 625 { // off the bottomright and the minimum visibility condition is satisified by |
| 616 // relocation. | 626 // relocation. |
| 617 gfx::Rect window_bounds; | 627 gfx::Rect window_bounds; |
| 618 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 628 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 619 gfx::Rect(995, 739, 500, 400), gfx::Rect(), PERSISTED, | 629 gfx::Rect(995, 739, 500, 400), gfx::Rect(), PERSISTED, |
| 620 &window_bounds, NULL); | 630 &window_bounds, NULL, gfx::Rect()); |
| 621 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 738 /* not 739 */, 500, 400), | 631 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 738 /* not 739 */, 500, 400), |
| 622 window_bounds); | 632 window_bounds); |
| 623 } | 633 } |
| 624 | 634 |
| 625 { // entirely off left | 635 { // entirely off left |
| 626 gfx::Rect window_bounds; | 636 gfx::Rect window_bounds; |
| 627 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 637 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 628 gfx::Rect(-700, 50, 500, 400), gfx::Rect(), PERSISTED, | 638 gfx::Rect(-700, 50, 500, 400), gfx::Rect(), PERSISTED, |
| 629 &window_bounds, NULL); | 639 &window_bounds, NULL, gfx::Rect()); |
| 630 EXPECT_EQ(gfx::Rect(-470 /* not -700 */, 50, 500, 400), window_bounds); | 640 EXPECT_EQ(gfx::Rect(-470 /* not -700 */, 50, 500, 400), window_bounds); |
| 631 } | 641 } |
| 632 | 642 |
| 633 { // entirely off left (monitor was detached since last run) | 643 { // entirely off left (monitor was detached since last run) |
| 634 gfx::Rect window_bounds; | 644 gfx::Rect window_bounds; |
| 635 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 645 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 636 gfx::Rect(-700, 50, 500, 400), left_nonprimary, PERSISTED, | 646 gfx::Rect(-700, 50, 500, 400), left_nonprimary, PERSISTED, |
| 637 &window_bounds, NULL); | 647 &window_bounds, NULL, gfx::Rect()); |
| 638 EXPECT_EQ(gfx::Rect(0, 50, 500, 400), window_bounds); | 648 EXPECT_EQ(gfx::Rect(0, 50, 500, 400), window_bounds); |
| 639 } | 649 } |
| 640 | 650 |
| 641 { // entirely off top | 651 { // entirely off top |
| 642 gfx::Rect window_bounds; | 652 gfx::Rect window_bounds; |
| 643 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 653 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 644 gfx::Rect(50, -500, 500, 400), gfx::Rect(), PERSISTED, | 654 gfx::Rect(50, -500, 500, 400), gfx::Rect(), PERSISTED, |
| 645 &window_bounds, NULL); | 655 &window_bounds, NULL, gfx::Rect()); |
| 646 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); | 656 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); |
| 647 } | 657 } |
| 648 | 658 |
| 649 { // entirely off top (monitor was detached since last run) | 659 { // entirely off top (monitor was detached since last run) |
| 650 gfx::Rect window_bounds; | 660 gfx::Rect window_bounds; |
| 651 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 661 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 652 gfx::Rect(50, -500, 500, 400), top_nonprimary, | 662 gfx::Rect(50, -500, 500, 400), top_nonprimary, |
| 653 PERSISTED, &window_bounds, NULL); | 663 PERSISTED, &window_bounds, NULL, gfx::Rect()); |
| 654 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); | 664 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); |
| 655 } | 665 } |
| 656 | 666 |
| 657 { // entirely off right | 667 { // entirely off right |
| 658 gfx::Rect window_bounds; | 668 gfx::Rect window_bounds; |
| 659 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 669 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 660 gfx::Rect(1200, 50, 500, 400), gfx::Rect(), PERSISTED, | 670 gfx::Rect(1200, 50, 500, 400), gfx::Rect(), PERSISTED, |
| 661 &window_bounds, NULL); | 671 &window_bounds, NULL, gfx::Rect()); |
| 662 EXPECT_EQ(gfx::Rect(994 /* not 1200 */, 50, 500, 400), window_bounds); | 672 EXPECT_EQ(gfx::Rect(994 /* not 1200 */, 50, 500, 400), window_bounds); |
| 663 } | 673 } |
| 664 | 674 |
| 665 { // entirely off right (monitor was detached since last run) | 675 { // entirely off right (monitor was detached since last run) |
| 666 gfx::Rect window_bounds; | 676 gfx::Rect window_bounds; |
| 667 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 677 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 668 gfx::Rect(1200, 50, 500, 400), right_nonprimary, | 678 gfx::Rect(1200, 50, 500, 400), right_nonprimary, |
| 669 PERSISTED, &window_bounds, NULL); | 679 PERSISTED, &window_bounds, NULL, gfx::Rect()); |
| 670 EXPECT_EQ(gfx::Rect(524, 50, 500, 400), window_bounds); | 680 EXPECT_EQ(gfx::Rect(524, 50, 500, 400), window_bounds); |
| 671 } | 681 } |
| 672 | 682 |
| 673 { // entirely off bottom | 683 { // entirely off bottom |
| 674 gfx::Rect window_bounds; | 684 gfx::Rect window_bounds; |
| 675 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 685 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 676 gfx::Rect(50, 800, 500, 400), gfx::Rect(), PERSISTED, | 686 gfx::Rect(50, 800, 500, 400), gfx::Rect(), PERSISTED, |
| 677 &window_bounds, NULL); | 687 &window_bounds, NULL, gfx::Rect()); |
| 678 EXPECT_EQ(gfx::Rect(50, 738 /* not 800 */, 500, 400), window_bounds); | 688 EXPECT_EQ(gfx::Rect(50, 738 /* not 800 */, 500, 400), window_bounds); |
| 679 } | 689 } |
| 680 | 690 |
| 681 { // entirely off bottom (monitor was detached since last run) | 691 { // entirely off bottom (monitor was detached since last run) |
| 682 gfx::Rect window_bounds; | 692 gfx::Rect window_bounds; |
| 683 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 693 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 684 gfx::Rect(50, 800, 500, 400), bottom_nonprimary, | 694 gfx::Rect(50, 800, 500, 400), bottom_nonprimary, |
| 685 PERSISTED, &window_bounds, NULL); | 695 PERSISTED, &window_bounds, NULL, gfx::Rect()); |
| 686 EXPECT_EQ(gfx::Rect(50, 368, 500, 400), window_bounds); | 696 EXPECT_EQ(gfx::Rect(50, 368, 500, 400), window_bounds); |
| 687 } | 697 } |
| 688 } | 698 } |
| 699 |
| 700 // Test that the window is sized appropriately for the first run experience |
| 701 // where the default window bounds calculation is invoked. |
| 702 TEST(WindowSizerTest, AdjustFitSize) { |
| 703 { // Check that the window gets resized to the screen. |
| 704 gfx::Rect window_bounds; |
| 705 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(), |
| 706 gfx::Rect(), DEFAULT, &window_bounds, NULL, |
| 707 gfx::Rect(-10, -10, 1024 + 20, 768 + 20)); |
| 708 EXPECT_EQ(gfx::Rect(0, 0, 1024, 768), window_bounds); |
| 709 } |
| 710 |
| 711 { // Check that a window which hangs out of the screen get moved back in. |
| 712 gfx::Rect window_bounds; |
| 713 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(), |
| 714 gfx::Rect(), DEFAULT, &window_bounds, NULL, |
| 715 gfx::Rect(1020, 700, 100, 100)); |
| 716 EXPECT_EQ(gfx::Rect(924, 668, 100, 100), window_bounds); |
| 717 } |
| 718 } |
| 719 |
| 689 #endif //defined(OS_MACOSX) | 720 #endif //defined(OS_MACOSX) |
| OLD | NEW |