| 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 "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| 11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
| 12 #include "ash/test/test_shell_delegate.h" | 12 #include "ash/test/test_shell_delegate.h" |
| 13 #include "ash/wm/window_resizer.h" |
| 13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 14 #include "base/logging.h" | 15 #include "base/logging.h" |
| 15 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/window_sizer_common_unittest.h" | 17 #include "chrome/browser/ui/window_sizer_common_unittest.h" |
| 17 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
| 18 #include "chrome/test/base/test_browser_window.h" | 19 #include "chrome/test/base/test_browser_window.h" |
| 19 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/test/render_view_test.h" | 21 #include "content/test/render_view_test.h" |
| 21 #include "content/test/test_browser_thread.h" | 22 #include "content/test/test_browser_thread.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 aura::Window *native_window) : | 77 aura::Window *native_window) : |
| 77 TestBrowserWindow(browser), | 78 TestBrowserWindow(browser), |
| 78 native_window_(native_window) { | 79 native_window_(native_window) { |
| 79 } | 80 } |
| 80 | 81 |
| 81 TestBrowserWindowAura::~TestBrowserWindowAura() {} | 82 TestBrowserWindowAura::~TestBrowserWindowAura() {} |
| 82 | 83 |
| 83 // Test that the window is sized appropriately for the first run experience | 84 // Test that the window is sized appropriately for the first run experience |
| 84 // where the default window bounds calculation is invoked. | 85 // where the default window bounds calculation is invoked. |
| 85 TEST_F(WindowSizerTest, DefaultSizeCase) { | 86 TEST_F(WindowSizerTest, DefaultSizeCase) { |
| 86 EXPECT_EQ(WindowSizer::kDesktopBorderSize, | 87 int grid = ash::Shell::GetInstance()->GetGridSize(); |
| 87 ash::Shell::GetInstance()->GetGridSize()); | 88 EXPECT_EQ(WindowSizer::kDesktopBorderSize, grid); |
| 88 { // 4:3 monitor case, 1024x768, no taskbar | 89 { // 4:3 monitor case, 1024x768, no taskbar |
| 89 gfx::Rect window_bounds; | 90 gfx::Rect window_bounds; |
| 90 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(), | 91 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(), |
| 91 gfx::Rect(), DEFAULT, &window_bounds, NULL); | 92 gfx::Rect(), DEFAULT, &window_bounds, NULL); |
| 92 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, | 93 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, |
| 93 WindowSizer::kDesktopBorderSize, | 94 WindowSizer::kDesktopBorderSize, |
| 94 1024 - WindowSizer::kDesktopBorderSize * 2, | 95 1024 - WindowSizer::kDesktopBorderSize * 2, |
| 95 768 - WindowSizer::kDesktopBorderSize), | 96 768 - WindowSizer::kDesktopBorderSize), |
| 96 window_bounds); | 97 window_bounds); |
| 97 } | 98 } |
| 98 | 99 |
| 99 { // 4:3 monitor case, 1024x768, taskbar on bottom | 100 { // 4:3 monitor case, 1024x768, taskbar on bottom |
| 100 gfx::Rect window_bounds; | 101 gfx::Rect window_bounds; |
| 101 GetWindowBounds(tentwentyfour, taskbar_bottom_work_area, gfx::Rect(), | 102 GetWindowBounds(tentwentyfour, taskbar_bottom_work_area, gfx::Rect(), |
| 102 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL); | 103 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL); |
| 103 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, | 104 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, |
| 104 WindowSizer::kDesktopBorderSize, | 105 WindowSizer::kDesktopBorderSize, |
| 105 1024 - WindowSizer::kDesktopBorderSize * 2, | 106 1024 - WindowSizer::kDesktopBorderSize * 2, |
| 106 (taskbar_bottom_work_area.height() - | 107 ash::WindowResizer::AlignToGridRoundDown( |
| 107 WindowSizer::kDesktopBorderSize)), | 108 taskbar_bottom_work_area.height() - |
| 108 window_bounds); | 109 WindowSizer::kDesktopBorderSize, grid)), |
| 110 window_bounds); |
| 109 } | 111 } |
| 110 | 112 |
| 111 { // 4:3 monitor case, 1024x768, taskbar on right | 113 { // 4:3 monitor case, 1024x768, taskbar on right |
| 112 gfx::Rect window_bounds; | 114 gfx::Rect window_bounds; |
| 113 GetWindowBounds(tentwentyfour, taskbar_right_work_area, gfx::Rect(), | 115 GetWindowBounds(tentwentyfour, taskbar_right_work_area, gfx::Rect(), |
| 114 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL); | 116 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL); |
| 115 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, | 117 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, |
| 116 WindowSizer::kDesktopBorderSize, | 118 WindowSizer::kDesktopBorderSize, |
| 117 taskbar_right_work_area.width() - | 119 ash::WindowResizer::AlignToGridRoundDown( |
| 118 WindowSizer::kDesktopBorderSize*2, | 120 taskbar_right_work_area.width() - |
| 121 WindowSizer::kDesktopBorderSize * 2, grid), |
| 119 768 - WindowSizer::kDesktopBorderSize), | 122 768 - WindowSizer::kDesktopBorderSize), |
| 120 window_bounds); | 123 window_bounds); |
| 121 } | 124 } |
| 122 | 125 |
| 123 { // 4:3 monitor case, 1024x768, taskbar on left | 126 { // 4:3 monitor case, 1024x768, taskbar on left |
| 124 gfx::Rect window_bounds; | 127 gfx::Rect window_bounds; |
| 125 GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(), | 128 GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(), |
| 126 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL); | 129 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL); |
| 127 EXPECT_EQ(gfx::Rect(taskbar_left_work_area.x() + | 130 EXPECT_EQ(gfx::Rect(taskbar_left_work_area.x() + |
| 128 WindowSizer::kDesktopBorderSize, | 131 WindowSizer::kDesktopBorderSize, |
| 129 WindowSizer::kDesktopBorderSize, | 132 WindowSizer::kDesktopBorderSize, |
| 130 taskbar_left_work_area.width() - | 133 ash::WindowResizer::AlignToGridRoundDown( |
| 131 WindowSizer::kDesktopBorderSize * 2, | 134 taskbar_left_work_area.width() - |
| 132 taskbar_left_work_area.height() - | 135 WindowSizer::kDesktopBorderSize * 2, grid), |
| 133 WindowSizer::kDesktopBorderSize), | 136 ash::WindowResizer::AlignToGridRoundDown( |
| 137 taskbar_left_work_area.height() - |
| 138 WindowSizer::kDesktopBorderSize, grid)), |
| 134 window_bounds); | 139 window_bounds); |
| 135 } | 140 } |
| 136 | 141 |
| 137 { // 4:3 monitor case, 1024x768, taskbar on top | 142 { // 4:3 monitor case, 1024x768, taskbar on top |
| 138 gfx::Rect window_bounds; | 143 gfx::Rect window_bounds; |
| 139 GetWindowBounds(tentwentyfour, taskbar_top_work_area, gfx::Rect(), | 144 GetWindowBounds(tentwentyfour, taskbar_top_work_area, gfx::Rect(), |
| 140 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL); | 145 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL); |
| 141 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, | 146 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, |
| 142 taskbar_top_work_area.y() + | 147 taskbar_top_work_area.y() + |
| 143 WindowSizer::kDesktopBorderSize, | 148 WindowSizer::kDesktopBorderSize, |
| 144 1024 - WindowSizer::kDesktopBorderSize * 2, | 149 1024 - WindowSizer::kDesktopBorderSize * 2, |
| 145 taskbar_top_work_area.height() - | 150 ash::WindowResizer::AlignToGridRoundDown( |
| 146 WindowSizer::kDesktopBorderSize), | 151 taskbar_top_work_area.height() - |
| 152 WindowSizer::kDesktopBorderSize, grid)), |
| 147 window_bounds); | 153 window_bounds); |
| 148 } | 154 } |
| 149 | 155 |
| 150 { // 4:3 monitor case, 1280x1024 | 156 { // 4:3 monitor case, 1280x1024 |
| 151 gfx::Rect window_bounds; | 157 gfx::Rect window_bounds; |
| 152 GetWindowBounds(twelveeighty, twelveeighty, gfx::Rect(), gfx::Rect(), | 158 GetWindowBounds(twelveeighty, twelveeighty, gfx::Rect(), gfx::Rect(), |
| 153 gfx::Rect(), DEFAULT, &window_bounds, NULL); | 159 gfx::Rect(), DEFAULT, &window_bounds, NULL); |
| 154 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, | 160 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, |
| 155 WindowSizer::kDesktopBorderSize, | 161 WindowSizer::kDesktopBorderSize, |
| 156 1280 - 2 * WindowSizer::kDesktopBorderSize, | 162 1280 - 2 * WindowSizer::kDesktopBorderSize, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 167 1200 - WindowSizer::kDesktopBorderSize), | 173 1200 - WindowSizer::kDesktopBorderSize), |
| 168 window_bounds); | 174 window_bounds); |
| 169 } | 175 } |
| 170 | 176 |
| 171 { // 16:10 monitor case, 1680x1050 | 177 { // 16:10 monitor case, 1680x1050 |
| 172 gfx::Rect window_bounds; | 178 gfx::Rect window_bounds; |
| 173 GetWindowBounds(sixteeneighty, sixteeneighty, gfx::Rect(), gfx::Rect(), | 179 GetWindowBounds(sixteeneighty, sixteeneighty, gfx::Rect(), gfx::Rect(), |
| 174 gfx::Rect(), DEFAULT, &window_bounds, NULL); | 180 gfx::Rect(), DEFAULT, &window_bounds, NULL); |
| 175 EXPECT_EQ(gfx::Rect((1680 - 1280) / 2, WindowSizer::kDesktopBorderSize, | 181 EXPECT_EQ(gfx::Rect((1680 - 1280) / 2, WindowSizer::kDesktopBorderSize, |
| 176 1280, | 182 1280, |
| 177 1050 - WindowSizer::kDesktopBorderSize), | 183 ash::WindowResizer::AlignToGridRoundDown( |
| 184 1050 - WindowSizer::kDesktopBorderSize, |
| 185 grid)), |
| 178 window_bounds); | 186 window_bounds); |
| 179 } | 187 } |
| 180 | 188 |
| 181 { // 16:10 monitor case, 1920x1200 | 189 { // 16:10 monitor case, 1920x1200 |
| 182 gfx::Rect window_bounds; | 190 gfx::Rect window_bounds; |
| 183 GetWindowBounds(nineteentwenty, nineteentwenty, gfx::Rect(), gfx::Rect(), | 191 GetWindowBounds(nineteentwenty, nineteentwenty, gfx::Rect(), gfx::Rect(), |
| 184 gfx::Rect(), DEFAULT, &window_bounds, NULL); | 192 gfx::Rect(), DEFAULT, &window_bounds, NULL); |
| 185 EXPECT_EQ(gfx::Rect((1920 - 1280) / 2, WindowSizer::kDesktopBorderSize, | 193 EXPECT_EQ(gfx::Rect((1920 - 1280) / 2, WindowSizer::kDesktopBorderSize, |
| 186 1280, | 194 1280, |
| 187 1200 - WindowSizer::kDesktopBorderSize), | 195 1200 - WindowSizer::kDesktopBorderSize), |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 667 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 660 gfx::Rect(50, 100, 300, 150), bottom_nonprimary, | 668 gfx::Rect(50, 100, 300, 150), bottom_nonprimary, |
| 661 PERSISTED, &window_bounds, browser.get()); | 669 PERSISTED, &window_bounds, browser.get()); |
| 662 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, | 670 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, |
| 663 WindowSizer::kDesktopBorderSize, | 671 WindowSizer::kDesktopBorderSize, |
| 664 1024 - 2 * WindowSizer::kDesktopBorderSize, | 672 1024 - 2 * WindowSizer::kDesktopBorderSize, |
| 665 768 - WindowSizer::kDesktopBorderSize), | 673 768 - WindowSizer::kDesktopBorderSize), |
| 666 window_bounds); | 674 window_bounds); |
| 667 } | 675 } |
| 668 } | 676 } |
| OLD | NEW |