| 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/panels/base_panel_browser_test.h" | 5 #include "chrome/browser/ui/panels/base_panel_browser_test.h" |
| 6 #include "chrome/browser/ui/panels/detached_panel_collection.h" | 6 #include "chrome/browser/ui/panels/detached_panel_collection.h" |
| 7 #include "chrome/browser/ui/panels/panel.h" | 7 #include "chrome/browser/ui/panels/panel.h" |
| 8 #include "chrome/browser/ui/panels/panel_manager.h" | 8 #include "chrome/browser/ui/panels/panel_manager.h" |
| 9 #include "chrome/browser/ui/panels/panel_resize_controller.h" | 9 #include "chrome/browser/ui/panels/panel_resize_controller.h" |
| 10 #include "chrome/browser/ui/panels/stacked_panel_collection.h" | 10 #include "chrome/browser/ui/panels/stacked_panel_collection.h" |
| 11 #include "ui/base/hit_test.h" |
| 11 | 12 |
| 12 class PanelResizeBrowserTest : public BasePanelBrowserTest { | 13 class PanelResizeBrowserTest : public BasePanelBrowserTest { |
| 13 public: | 14 public: |
| 14 PanelResizeBrowserTest() : BasePanelBrowserTest() { | 15 PanelResizeBrowserTest() : BasePanelBrowserTest() { |
| 15 } | 16 } |
| 16 | 17 |
| 17 virtual ~PanelResizeBrowserTest() { | 18 virtual ~PanelResizeBrowserTest() { |
| 18 } | 19 } |
| 19 | 20 |
| 20 virtual void SetUpOnMainThread() OVERRIDE { | 21 virtual void SetUpOnMainThread() OVERRIDE { |
| 21 BasePanelBrowserTest::SetUpOnMainThread(); | 22 BasePanelBrowserTest::SetUpOnMainThread(); |
| 22 | 23 |
| 23 // All the tests here assume using mocked 800x600 display area for the | 24 // All the tests here assume using mocked 800x600 display area for the |
| 24 // primary monitor. Do the check now. | 25 // primary monitor. Do the check now. |
| 25 gfx::Rect primary_display_area = PanelManager::GetInstance()-> | 26 gfx::Rect primary_display_area = PanelManager::GetInstance()-> |
| 26 display_settings_provider()->GetPrimaryDisplayArea(); | 27 display_settings_provider()->GetPrimaryDisplayArea(); |
| 27 DCHECK(primary_display_area.width() == 800); | 28 DCHECK(primary_display_area.width() == 800); |
| 28 DCHECK(primary_display_area.height() == 600); | 29 DCHECK(primary_display_area.height() == 600); |
| 29 } | 30 } |
| 30 | 31 |
| 31 void ResizePanel(Panel* panel, | 32 void ResizePanel(Panel* panel, |
| 32 panel::ResizingSides sides, | 33 int component, |
| 33 const gfx::Vector2d& delta) { | 34 const gfx::Vector2d& delta) { |
| 34 PanelManager* panel_manager = PanelManager::GetInstance(); | 35 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 35 gfx::Rect bounds = panel->GetBounds(); | 36 gfx::Rect bounds = panel->GetBounds(); |
| 36 gfx::Point mouse_location; | 37 gfx::Point mouse_location; |
| 37 switch (sides) { | 38 switch (component) { |
| 38 case panel::RESIZE_TOP_LEFT: | 39 case HTTOPLEFT: |
| 39 mouse_location = bounds.origin(); | 40 mouse_location = bounds.origin(); |
| 40 break; | 41 break; |
| 41 case panel::RESIZE_TOP: | 42 case HTTOP: |
| 42 mouse_location.SetPoint(bounds.x() + bounds.width() / 2, bounds.y()); | 43 mouse_location.SetPoint(bounds.x() + bounds.width() / 2, bounds.y()); |
| 43 break; | 44 break; |
| 44 case panel::RESIZE_TOP_RIGHT: | 45 case HTTOPRIGHT: |
| 45 mouse_location.SetPoint(bounds.right(), bounds.y()); | 46 mouse_location.SetPoint(bounds.right(), bounds.y()); |
| 46 break; | 47 break; |
| 47 case panel::RESIZE_LEFT: | 48 case HTLEFT: |
| 48 mouse_location.SetPoint(bounds.x(), bounds.y() + bounds.height() / 2); | 49 mouse_location.SetPoint(bounds.x(), bounds.y() + bounds.height() / 2); |
| 49 break; | 50 break; |
| 50 case panel::RESIZE_RIGHT: | 51 case HTRIGHT: |
| 51 mouse_location.SetPoint(bounds.right(), | 52 mouse_location.SetPoint(bounds.right(), |
| 52 bounds.y() + bounds.height() / 2); | 53 bounds.y() + bounds.height() / 2); |
| 53 break; | 54 break; |
| 54 case panel::RESIZE_BOTTOM_LEFT: | 55 case HTBOTTOMLEFT: |
| 55 mouse_location.SetPoint(bounds.x(), bounds.bottom()); | 56 mouse_location.SetPoint(bounds.x(), bounds.bottom()); |
| 56 break; | 57 break; |
| 57 case panel::RESIZE_BOTTOM: | 58 case HTBOTTOM: |
| 58 mouse_location.SetPoint(bounds.x() + bounds.width() / 2, | 59 mouse_location.SetPoint(bounds.x() + bounds.width() / 2, |
| 59 bounds.bottom()); | 60 bounds.bottom()); |
| 60 break; | 61 break; |
| 61 case panel::RESIZE_BOTTOM_RIGHT: | 62 case HTBOTTOMRIGHT: |
| 62 mouse_location.SetPoint(bounds.right(), bounds.bottom()); | 63 mouse_location.SetPoint(bounds.right(), bounds.bottom()); |
| 63 break; | 64 break; |
| 64 default: | 65 default: |
| 65 NOTREACHED(); | 66 NOTREACHED(); |
| 66 break; | 67 break; |
| 67 } | 68 } |
| 68 panel_manager->StartResizingByMouse(panel, mouse_location, sides); | 69 panel_manager->StartResizingByMouse(panel, mouse_location, component); |
| 69 mouse_location += delta; | 70 mouse_location += delta; |
| 70 panel_manager->ResizeByMouse(mouse_location); | 71 panel_manager->ResizeByMouse(mouse_location); |
| 71 panel_manager->EndResizingByMouse(false); | 72 panel_manager->EndResizingByMouse(false); |
| 72 } | 73 } |
| 73 }; | 74 }; |
| 74 | 75 |
| 75 // http://crbug.com/175760; several panel tests failing regularly on mac. | 76 // http://crbug.com/175760; several panel tests failing regularly on mac. |
| 76 #if defined(OS_MACOSX) | 77 #if defined(OS_MACOSX) |
| 77 #define MAYBE_DockedPanelResizability DISABLED_DockedPanelResizability | 78 #define MAYBE_DockedPanelResizability DISABLED_DockedPanelResizability |
| 78 #else | 79 #else |
| 79 #define MAYBE_DockedPanelResizability DockedPanelResizability | 80 #define MAYBE_DockedPanelResizability DockedPanelResizability |
| 80 #endif | 81 #endif |
| 81 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, MAYBE_DockedPanelResizability) { | 82 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, MAYBE_DockedPanelResizability) { |
| 82 PanelManager* panel_manager = PanelManager::GetInstance(); | 83 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 83 Panel* panel = CreatePanel("Panel"); | 84 Panel* panel = CreatePanel("Panel"); |
| 84 | 85 |
| 85 EXPECT_EQ(panel::RESIZABLE_EXCEPT_BOTTOM, panel->CanResizeByMouse()); | 86 EXPECT_EQ(panel::RESIZABLE_EXCEPT_BOTTOM, panel->CanResizeByMouse()); |
| 86 | 87 |
| 87 gfx::Rect bounds = panel->GetBounds(); | 88 gfx::Rect bounds = panel->GetBounds(); |
| 88 | 89 |
| 89 // Try resizing by the top left corner. | 90 // Try resizing by the top left corner. |
| 90 gfx::Point mouse_location = bounds.origin(); | 91 gfx::Point mouse_location = bounds.origin(); |
| 91 panel_manager->StartResizingByMouse(panel, mouse_location, | 92 panel_manager->StartResizingByMouse(panel, mouse_location, HTTOPLEFT); |
| 92 panel::RESIZE_TOP_LEFT); | |
| 93 mouse_location.Offset(-20, -10); | 93 mouse_location.Offset(-20, -10); |
| 94 panel_manager->ResizeByMouse(mouse_location); | 94 panel_manager->ResizeByMouse(mouse_location); |
| 95 | 95 |
| 96 bounds.set_size(gfx::Size(bounds.width() + 20, bounds.height() + 10)); | 96 bounds.set_size(gfx::Size(bounds.width() + 20, bounds.height() + 10)); |
| 97 bounds.Offset(-20, -10); | 97 bounds.Offset(-20, -10); |
| 98 EXPECT_EQ(bounds, panel->GetBounds()); | 98 EXPECT_EQ(bounds, panel->GetBounds()); |
| 99 | 99 |
| 100 panel_manager->EndResizingByMouse(false); | 100 panel_manager->EndResizingByMouse(false); |
| 101 EXPECT_EQ(bounds, panel->GetBounds()); | 101 EXPECT_EQ(bounds, panel->GetBounds()); |
| 102 | 102 |
| 103 // Try resizing by the top. | 103 // Try resizing by the top. |
| 104 mouse_location = bounds.origin() + gfx::Vector2d(10, 1); | 104 mouse_location = bounds.origin() + gfx::Vector2d(10, 1); |
| 105 panel_manager->StartResizingByMouse(panel, mouse_location, | 105 panel_manager->StartResizingByMouse(panel, mouse_location, HTTOP); |
| 106 panel::RESIZE_TOP); | |
| 107 mouse_location.Offset(5, -10); | 106 mouse_location.Offset(5, -10); |
| 108 panel_manager->ResizeByMouse(mouse_location); | 107 panel_manager->ResizeByMouse(mouse_location); |
| 109 | 108 |
| 110 bounds.set_height(bounds.height() + 10); | 109 bounds.set_height(bounds.height() + 10); |
| 111 bounds.Offset(0, -10); | 110 bounds.Offset(0, -10); |
| 112 EXPECT_EQ(bounds, panel->GetBounds()); | 111 EXPECT_EQ(bounds, panel->GetBounds()); |
| 113 | 112 |
| 114 panel_manager->EndResizingByMouse(false); | 113 panel_manager->EndResizingByMouse(false); |
| 115 EXPECT_EQ(bounds, panel->GetBounds()); | 114 EXPECT_EQ(bounds, panel->GetBounds()); |
| 116 | 115 |
| 117 // Try resizing by the left side. | 116 // Try resizing by the left side. |
| 118 mouse_location = bounds.origin() + gfx::Vector2d(1, 30); | 117 mouse_location = bounds.origin() + gfx::Vector2d(1, 30); |
| 119 panel_manager->StartResizingByMouse(panel, mouse_location, | 118 panel_manager->StartResizingByMouse(panel, mouse_location, HTLEFT); |
| 120 panel::RESIZE_LEFT); | |
| 121 mouse_location.Offset(-5, 25); | 119 mouse_location.Offset(-5, 25); |
| 122 panel_manager->ResizeByMouse(mouse_location); | 120 panel_manager->ResizeByMouse(mouse_location); |
| 123 | 121 |
| 124 bounds.set_width(bounds.width() + 5); | 122 bounds.set_width(bounds.width() + 5); |
| 125 bounds.Offset(-5, 0); | 123 bounds.Offset(-5, 0); |
| 126 EXPECT_EQ(bounds, panel->GetBounds()); | 124 EXPECT_EQ(bounds, panel->GetBounds()); |
| 127 | 125 |
| 128 panel_manager->EndResizingByMouse(false); | 126 panel_manager->EndResizingByMouse(false); |
| 129 EXPECT_EQ(bounds, panel->GetBounds()); | 127 EXPECT_EQ(bounds, panel->GetBounds()); |
| 130 | 128 |
| 131 // Try resizing by the top right side. | 129 // Try resizing by the top right side. |
| 132 mouse_location = bounds.origin() + gfx::Vector2d(bounds.width() - 1, 2); | 130 mouse_location = bounds.origin() + gfx::Vector2d(bounds.width() - 1, 2); |
| 133 panel_manager->StartResizingByMouse(panel, mouse_location, | 131 panel_manager->StartResizingByMouse(panel, mouse_location, HTTOPRIGHT); |
| 134 panel::RESIZE_TOP_RIGHT); | |
| 135 mouse_location.Offset(30, 20); | 132 mouse_location.Offset(30, 20); |
| 136 panel_manager->ResizeByMouse(mouse_location); | 133 panel_manager->ResizeByMouse(mouse_location); |
| 137 | 134 |
| 138 bounds.set_size(gfx::Size(bounds.width() + 30, bounds.height() - 20)); | 135 bounds.set_size(gfx::Size(bounds.width() + 30, bounds.height() - 20)); |
| 139 bounds.Offset(0, 20); | 136 bounds.Offset(0, 20); |
| 140 EXPECT_EQ(bounds, panel->GetBounds()); | 137 EXPECT_EQ(bounds, panel->GetBounds()); |
| 141 | 138 |
| 142 panel_manager->EndResizingByMouse(false); | 139 panel_manager->EndResizingByMouse(false); |
| 143 WaitForBoundsAnimationFinished(panel); | 140 WaitForBoundsAnimationFinished(panel); |
| 144 bounds.Offset(-30, 0); // Layout of panel adjusted in docked collection. | 141 bounds.Offset(-30, 0); // Layout of panel adjusted in docked collection. |
| 145 EXPECT_EQ(bounds, panel->GetBounds()); | 142 EXPECT_EQ(bounds, panel->GetBounds()); |
| 146 | 143 |
| 147 // Try resizing by the right side. | 144 // Try resizing by the right side. |
| 148 mouse_location = bounds.origin() + gfx::Vector2d(bounds.width() - 1, 30); | 145 mouse_location = bounds.origin() + gfx::Vector2d(bounds.width() - 1, 30); |
| 149 panel_manager->StartResizingByMouse(panel, mouse_location, | 146 panel_manager->StartResizingByMouse(panel, mouse_location, HTRIGHT); |
| 150 panel::RESIZE_RIGHT); | |
| 151 mouse_location.Offset(5, 25); | 147 mouse_location.Offset(5, 25); |
| 152 panel_manager->ResizeByMouse(mouse_location); | 148 panel_manager->ResizeByMouse(mouse_location); |
| 153 | 149 |
| 154 bounds.set_width(bounds.width() + 5); | 150 bounds.set_width(bounds.width() + 5); |
| 155 EXPECT_EQ(bounds, panel->GetBounds()); | 151 EXPECT_EQ(bounds, panel->GetBounds()); |
| 156 | 152 |
| 157 panel_manager->EndResizingByMouse(false); | 153 panel_manager->EndResizingByMouse(false); |
| 158 WaitForBoundsAnimationFinished(panel); | 154 WaitForBoundsAnimationFinished(panel); |
| 159 bounds.Offset(-5, 0); // Layout of panel adjusted in docked collection. | 155 bounds.Offset(-5, 0); // Layout of panel adjusted in docked collection. |
| 160 EXPECT_EQ(bounds, panel->GetBounds()); | 156 EXPECT_EQ(bounds, panel->GetBounds()); |
| 161 | 157 |
| 162 // Try resizing by the bottom side; verify resize won't work. | 158 // Try resizing by the bottom side; verify resize won't work. |
| 163 mouse_location = bounds.origin() + gfx::Vector2d(10, bounds.height() - 1); | 159 mouse_location = bounds.origin() + gfx::Vector2d(10, bounds.height() - 1); |
| 164 panel_manager->StartResizingByMouse(panel, mouse_location, | 160 panel_manager->StartResizingByMouse(panel, mouse_location, HTBOTTOM); |
| 165 panel::RESIZE_BOTTOM); | |
| 166 mouse_location.Offset(30, -10); | 161 mouse_location.Offset(30, -10); |
| 167 panel_manager->ResizeByMouse(mouse_location); | 162 panel_manager->ResizeByMouse(mouse_location); |
| 168 EXPECT_EQ(bounds, panel->GetBounds()); | 163 EXPECT_EQ(bounds, panel->GetBounds()); |
| 169 | 164 |
| 170 panel_manager->EndResizingByMouse(false); | 165 panel_manager->EndResizingByMouse(false); |
| 171 EXPECT_EQ(bounds, panel->GetBounds()); | 166 EXPECT_EQ(bounds, panel->GetBounds()); |
| 172 | 167 |
| 173 // Try resizing by the bottom left corner; verify resize won't work. | 168 // Try resizing by the bottom left corner; verify resize won't work. |
| 174 mouse_location = bounds.origin() + gfx::Vector2d(1, bounds.height() - 1); | 169 mouse_location = bounds.origin() + gfx::Vector2d(1, bounds.height() - 1); |
| 175 panel_manager->StartResizingByMouse(panel, mouse_location, | 170 panel_manager->StartResizingByMouse(panel, mouse_location, HTBOTTOMLEFT); |
| 176 panel::RESIZE_BOTTOM_LEFT); | |
| 177 mouse_location.Offset(-10, 15); | 171 mouse_location.Offset(-10, 15); |
| 178 panel_manager->ResizeByMouse(mouse_location); | 172 panel_manager->ResizeByMouse(mouse_location); |
| 179 EXPECT_EQ(bounds, panel->GetBounds()); | 173 EXPECT_EQ(bounds, panel->GetBounds()); |
| 180 | 174 |
| 181 panel_manager->EndResizingByMouse(false); | 175 panel_manager->EndResizingByMouse(false); |
| 182 EXPECT_EQ(bounds, panel->GetBounds()); | 176 EXPECT_EQ(bounds, panel->GetBounds()); |
| 183 | 177 |
| 184 // Try resizing by the bottom right corner; verify resize won't work. | 178 // Try resizing by the bottom right corner; verify resize won't work. |
| 185 mouse_location = bounds.origin() + | 179 mouse_location = bounds.origin() + |
| 186 gfx::Vector2d(bounds.width() - 2, bounds.height()); | 180 gfx::Vector2d(bounds.width() - 2, bounds.height()); |
| 187 panel_manager->StartResizingByMouse(panel, mouse_location, | 181 panel_manager->StartResizingByMouse(panel, mouse_location, HTBOTTOMRIGHT); |
| 188 panel::RESIZE_BOTTOM_RIGHT); | |
| 189 mouse_location.Offset(20, 10); | 182 mouse_location.Offset(20, 10); |
| 190 panel_manager->ResizeByMouse(mouse_location); | 183 panel_manager->ResizeByMouse(mouse_location); |
| 191 EXPECT_EQ(bounds, panel->GetBounds()); | 184 EXPECT_EQ(bounds, panel->GetBounds()); |
| 192 | 185 |
| 193 panel_manager->EndResizingByMouse(false); | 186 panel_manager->EndResizingByMouse(false); |
| 194 EXPECT_EQ(bounds, panel->GetBounds()); | 187 EXPECT_EQ(bounds, panel->GetBounds()); |
| 195 | 188 |
| 196 panel->Close(); | 189 panel->Close(); |
| 197 } | 190 } |
| 198 | 191 |
| 199 // http://crbug.com/175760; several panel tests failing regularly on mac. | 192 // http://crbug.com/175760; several panel tests failing regularly on mac. |
| 200 #if defined(OS_MACOSX) | 193 #if defined(OS_MACOSX) |
| 201 #define MAYBE_ResizeDetachedPanel DISABLED_ResizeDetachedPanel | 194 #define MAYBE_ResizeDetachedPanel DISABLED_ResizeDetachedPanel |
| 202 #else | 195 #else |
| 203 #define MAYBE_ResizeDetachedPanel ResizeDetachedPanel | 196 #define MAYBE_ResizeDetachedPanel ResizeDetachedPanel |
| 204 #endif | 197 #endif |
| 205 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, MAYBE_ResizeDetachedPanel) { | 198 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, MAYBE_ResizeDetachedPanel) { |
| 206 PanelManager* panel_manager = PanelManager::GetInstance(); | 199 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 207 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); | 200 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); |
| 208 | 201 |
| 209 EXPECT_EQ(panel::RESIZABLE_ALL, panel->CanResizeByMouse()); | 202 EXPECT_EQ(panel::RESIZABLE_ALL, panel->CanResizeByMouse()); |
| 210 | 203 |
| 211 gfx::Rect bounds = panel->GetBounds(); | 204 gfx::Rect bounds = panel->GetBounds(); |
| 212 | 205 |
| 213 // Try resizing by the right side; verify resize will change width only. | 206 // Try resizing by the right side; verify resize will change width only. |
| 214 gfx::Point mouse_location = bounds.origin() + | 207 gfx::Point mouse_location = bounds.origin() + |
| 215 gfx::Vector2d(bounds.width() - 1, 30); | 208 gfx::Vector2d(bounds.width() - 1, 30); |
| 216 panel_manager->StartResizingByMouse(panel, mouse_location, | 209 panel_manager->StartResizingByMouse(panel, mouse_location, HTRIGHT); |
| 217 panel::RESIZE_RIGHT); | |
| 218 mouse_location.Offset(5, 25); | 210 mouse_location.Offset(5, 25); |
| 219 panel_manager->ResizeByMouse(mouse_location); | 211 panel_manager->ResizeByMouse(mouse_location); |
| 220 | 212 |
| 221 bounds.set_width(bounds.width() + 5); | 213 bounds.set_width(bounds.width() + 5); |
| 222 EXPECT_EQ(bounds, panel->GetBounds()); | 214 EXPECT_EQ(bounds, panel->GetBounds()); |
| 223 | 215 |
| 224 panel_manager->EndResizingByMouse(false); | 216 panel_manager->EndResizingByMouse(false); |
| 225 EXPECT_EQ(bounds, panel->GetBounds()); | 217 EXPECT_EQ(bounds, panel->GetBounds()); |
| 226 | 218 |
| 227 // Try resizing by the bottom left side. | 219 // Try resizing by the bottom left side. |
| 228 mouse_location = bounds.origin() + gfx::Vector2d(1, bounds.height() - 1); | 220 mouse_location = bounds.origin() + gfx::Vector2d(1, bounds.height() - 1); |
| 229 panel_manager->StartResizingByMouse(panel, mouse_location, | 221 panel_manager->StartResizingByMouse(panel, mouse_location, HTBOTTOMLEFT); |
| 230 panel::RESIZE_BOTTOM_LEFT); | |
| 231 mouse_location.Offset(-10, 15); | 222 mouse_location.Offset(-10, 15); |
| 232 panel_manager->ResizeByMouse(mouse_location); | 223 panel_manager->ResizeByMouse(mouse_location); |
| 233 | 224 |
| 234 bounds.set_size(gfx::Size(bounds.width() + 10, bounds.height() + 15)); | 225 bounds.set_size(gfx::Size(bounds.width() + 10, bounds.height() + 15)); |
| 235 bounds.Offset(-10, 0); | 226 bounds.Offset(-10, 0); |
| 236 EXPECT_EQ(bounds, panel->GetBounds()); | 227 EXPECT_EQ(bounds, panel->GetBounds()); |
| 237 | 228 |
| 238 panel_manager->EndResizingByMouse(false); | 229 panel_manager->EndResizingByMouse(false); |
| 239 EXPECT_EQ(bounds, panel->GetBounds()); | 230 EXPECT_EQ(bounds, panel->GetBounds()); |
| 240 | 231 |
| 241 // Try resizing by the top right side. | 232 // Try resizing by the top right side. |
| 242 mouse_location = bounds.origin() + gfx::Vector2d(bounds.width() - 1, 2); | 233 mouse_location = bounds.origin() + gfx::Vector2d(bounds.width() - 1, 2); |
| 243 panel_manager->StartResizingByMouse(panel, mouse_location, | 234 panel_manager->StartResizingByMouse(panel, mouse_location, HTTOPRIGHT); |
| 244 panel::RESIZE_TOP_RIGHT); | |
| 245 mouse_location.Offset(30, 20); | 235 mouse_location.Offset(30, 20); |
| 246 panel_manager->ResizeByMouse(mouse_location); | 236 panel_manager->ResizeByMouse(mouse_location); |
| 247 | 237 |
| 248 bounds.set_size(gfx::Size(bounds.width() + 30, bounds.height() - 20)); | 238 bounds.set_size(gfx::Size(bounds.width() + 30, bounds.height() - 20)); |
| 249 bounds.Offset(0, 20); | 239 bounds.Offset(0, 20); |
| 250 EXPECT_EQ(bounds, panel->GetBounds()); | 240 EXPECT_EQ(bounds, panel->GetBounds()); |
| 251 | 241 |
| 252 panel_manager->EndResizingByMouse(false); | 242 panel_manager->EndResizingByMouse(false); |
| 253 EXPECT_EQ(bounds, panel->GetBounds()); | 243 EXPECT_EQ(bounds, panel->GetBounds()); |
| 254 | 244 |
| 255 // Try resizing by the top left side. | 245 // Try resizing by the top left side. |
| 256 mouse_location = bounds.origin() + gfx::Vector2d(1, 0); | 246 mouse_location = bounds.origin() + gfx::Vector2d(1, 0); |
| 257 panel_manager->StartResizingByMouse(panel, mouse_location, | 247 panel_manager->StartResizingByMouse(panel, mouse_location, HTTOPLEFT); |
| 258 panel::RESIZE_TOP_LEFT); | |
| 259 mouse_location.Offset(-20, -10); | 248 mouse_location.Offset(-20, -10); |
| 260 panel_manager->ResizeByMouse(mouse_location); | 249 panel_manager->ResizeByMouse(mouse_location); |
| 261 | 250 |
| 262 bounds.set_size(gfx::Size(bounds.width() + 20, bounds.height() + 10)); | 251 bounds.set_size(gfx::Size(bounds.width() + 20, bounds.height() + 10)); |
| 263 bounds.Offset(-20, -10); | 252 bounds.Offset(-20, -10); |
| 264 EXPECT_EQ(bounds, panel->GetBounds()); | 253 EXPECT_EQ(bounds, panel->GetBounds()); |
| 265 | 254 |
| 266 panel_manager->EndResizingByMouse(false); | 255 panel_manager->EndResizingByMouse(false); |
| 267 EXPECT_EQ(bounds, panel->GetBounds()); | 256 EXPECT_EQ(bounds, panel->GetBounds()); |
| 268 | 257 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 281 int initial_width = 150; | 270 int initial_width = 150; |
| 282 int initial_height = 100; | 271 int initial_height = 100; |
| 283 Panel* panel = CreateDetachedPanel("1", | 272 Panel* panel = CreateDetachedPanel("1", |
| 284 gfx::Rect(300, 200, initial_width, initial_height)); | 273 gfx::Rect(300, 200, initial_width, initial_height)); |
| 285 | 274 |
| 286 // Try to resize the panel below the minimum size. Expect that the panel | 275 // Try to resize the panel below the minimum size. Expect that the panel |
| 287 // shrinks to the minimum size. | 276 // shrinks to the minimum size. |
| 288 int resize_width = panel::kPanelMinWidth / 2 - initial_width; | 277 int resize_width = panel::kPanelMinWidth / 2 - initial_width; |
| 289 int resize_height = panel::kPanelMinHeight / 2 - initial_height; | 278 int resize_height = panel::kPanelMinHeight / 2 - initial_height; |
| 290 ResizePanel(panel, | 279 ResizePanel(panel, |
| 291 panel::RESIZE_BOTTOM_RIGHT, | 280 HTBOTTOMRIGHT, |
| 292 gfx::Vector2d(resize_width, resize_height)); | 281 gfx::Vector2d(resize_width, resize_height)); |
| 293 | 282 |
| 294 EXPECT_EQ(panel::kPanelMinWidth, panel->GetBounds().width()); | 283 EXPECT_EQ(panel::kPanelMinWidth, panel->GetBounds().width()); |
| 295 EXPECT_EQ(panel::kPanelMinHeight, panel->GetBounds().height()); | 284 EXPECT_EQ(panel::kPanelMinHeight, panel->GetBounds().height()); |
| 296 | 285 |
| 297 PanelManager::GetInstance()->CloseAll(); | 286 PanelManager::GetInstance()->CloseAll(); |
| 298 } | 287 } |
| 299 | 288 |
| 300 // http://crbug.com/175760; several panel tests failing regularly on mac. | 289 // http://crbug.com/175760; several panel tests failing regularly on mac. |
| 301 #if defined(OS_MACOSX) | 290 #if defined(OS_MACOSX) |
| 302 #define MAYBE_ResizeDetachedPanelToClampSize \ | 291 #define MAYBE_ResizeDetachedPanelToClampSize \ |
| 303 DISABLED_ResizeDetachedPanelToClampSize | 292 DISABLED_ResizeDetachedPanelToClampSize |
| 304 #else | 293 #else |
| 305 #define MAYBE_ResizeDetachedPanelToClampSize ResizeDetachedPanelToClampSize | 294 #define MAYBE_ResizeDetachedPanelToClampSize ResizeDetachedPanelToClampSize |
| 306 #endif | 295 #endif |
| 307 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, | 296 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, |
| 308 MAYBE_ResizeDetachedPanelToClampSize) { | 297 MAYBE_ResizeDetachedPanelToClampSize) { |
| 309 PanelManager* panel_manager = PanelManager::GetInstance(); | 298 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 310 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); | 299 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); |
| 311 | 300 |
| 312 EXPECT_EQ(panel::RESIZABLE_ALL, panel->CanResizeByMouse()); | 301 EXPECT_EQ(panel::RESIZABLE_ALL, panel->CanResizeByMouse()); |
| 313 | 302 |
| 314 gfx::Rect bounds = panel->GetBounds(); | 303 gfx::Rect bounds = panel->GetBounds(); |
| 315 | 304 |
| 316 // Make sure the panel does not resize smaller than its min size. | 305 // Make sure the panel does not resize smaller than its min size. |
| 317 gfx::Point mouse_location = bounds.origin() + | 306 gfx::Point mouse_location = bounds.origin() + |
| 318 gfx::Vector2d(30, bounds.height() - 2); | 307 gfx::Vector2d(30, bounds.height() - 2); |
| 319 panel_manager->StartResizingByMouse(panel, mouse_location, | 308 panel_manager->StartResizingByMouse(panel, mouse_location, HTBOTTOM); |
| 320 panel::RESIZE_BOTTOM); | |
| 321 mouse_location.Offset(-20, -500); | 309 mouse_location.Offset(-20, -500); |
| 322 panel_manager->ResizeByMouse(mouse_location); | 310 panel_manager->ResizeByMouse(mouse_location); |
| 323 | 311 |
| 324 bounds.set_height(panel->min_size().height()); | 312 bounds.set_height(panel->min_size().height()); |
| 325 EXPECT_EQ(bounds, panel->GetBounds()); | 313 EXPECT_EQ(bounds, panel->GetBounds()); |
| 326 | 314 |
| 327 panel_manager->EndResizingByMouse(false); | 315 panel_manager->EndResizingByMouse(false); |
| 328 EXPECT_EQ(bounds, panel->GetBounds()); | 316 EXPECT_EQ(bounds, panel->GetBounds()); |
| 329 | 317 |
| 330 // Make sure the panel can resize larger than its size. User is in control. | 318 // Make sure the panel can resize larger than its size. User is in control. |
| 331 mouse_location = bounds.origin() + | 319 mouse_location = bounds.origin() + |
| 332 gfx::Vector2d(bounds.width(), bounds.height() - 2); | 320 gfx::Vector2d(bounds.width(), bounds.height() - 2); |
| 333 panel_manager->StartResizingByMouse(panel, mouse_location, | 321 panel_manager->StartResizingByMouse(panel, mouse_location, HTBOTTOMRIGHT); |
| 334 panel::RESIZE_BOTTOM_RIGHT); | |
| 335 | 322 |
| 336 // This drag would take us beyond max size. | 323 // This drag would take us beyond max size. |
| 337 int delta_x = panel->max_size().width() + 10 - panel->GetBounds().width(); | 324 int delta_x = panel->max_size().width() + 10 - panel->GetBounds().width(); |
| 338 int delta_y = panel->max_size().height() + 10 - panel->GetBounds().height(); | 325 int delta_y = panel->max_size().height() + 10 - panel->GetBounds().height(); |
| 339 mouse_location.Offset(delta_x, delta_y); | 326 mouse_location.Offset(delta_x, delta_y); |
| 340 panel_manager->ResizeByMouse(mouse_location); | 327 panel_manager->ResizeByMouse(mouse_location); |
| 341 | 328 |
| 342 // The bounds if the max_size does not limit the resize. | 329 // The bounds if the max_size does not limit the resize. |
| 343 bounds.set_size(gfx::Size(bounds.width() + delta_x, | 330 bounds.set_size(gfx::Size(bounds.width() + delta_x, |
| 344 bounds.height() + delta_y)); | 331 bounds.height() + delta_y)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 370 ASSERT_EQ(3, detached_collection->num_panels()); | 357 ASSERT_EQ(3, detached_collection->num_panels()); |
| 371 | 358 |
| 372 gfx::Rect panel1_bounds = panel1->GetBounds(); | 359 gfx::Rect panel1_bounds = panel1->GetBounds(); |
| 373 gfx::Rect panel2_bounds = panel2->GetBounds(); | 360 gfx::Rect panel2_bounds = panel2->GetBounds(); |
| 374 gfx::Rect panel3_bounds = panel3->GetBounds(); | 361 gfx::Rect panel3_bounds = panel3->GetBounds(); |
| 375 | 362 |
| 376 // Start resizing panel1, and close panel2 in the process. | 363 // Start resizing panel1, and close panel2 in the process. |
| 377 // Panel1 is not affected. | 364 // Panel1 is not affected. |
| 378 gfx::Point mouse_location = panel1_bounds.origin() + | 365 gfx::Point mouse_location = panel1_bounds.origin() + |
| 379 gfx::Vector2d(1, panel1_bounds.height() - 1); | 366 gfx::Vector2d(1, panel1_bounds.height() - 1); |
| 380 panel_manager->StartResizingByMouse(panel1, mouse_location, | 367 panel_manager->StartResizingByMouse(panel1, mouse_location, HTBOTTOMLEFT); |
| 381 panel::RESIZE_BOTTOM_LEFT); | |
| 382 mouse_location.Offset(-10, 15); | 368 mouse_location.Offset(-10, 15); |
| 383 panel_manager->ResizeByMouse(mouse_location); | 369 panel_manager->ResizeByMouse(mouse_location); |
| 384 | 370 |
| 385 panel1_bounds.set_size(gfx::Size(panel1_bounds.width() + 10, | 371 panel1_bounds.set_size(gfx::Size(panel1_bounds.width() + 10, |
| 386 panel1_bounds.height() + 15)); | 372 panel1_bounds.height() + 15)); |
| 387 panel1_bounds.Offset(-10, 0); | 373 panel1_bounds.Offset(-10, 0); |
| 388 EXPECT_EQ(panel1_bounds, panel1->GetBounds()); | 374 EXPECT_EQ(panel1_bounds, panel1->GetBounds()); |
| 389 | 375 |
| 390 CloseWindowAndWait(panel2); | 376 CloseWindowAndWait(panel2); |
| 391 EXPECT_TRUE(resize_controller->IsResizing()); | 377 EXPECT_TRUE(resize_controller->IsResizing()); |
| 392 EXPECT_EQ(2, detached_collection->num_panels()); | 378 EXPECT_EQ(2, detached_collection->num_panels()); |
| 393 | 379 |
| 394 panel_manager->EndResizingByMouse(false); | 380 panel_manager->EndResizingByMouse(false); |
| 395 EXPECT_EQ(panel1_bounds, panel1->GetBounds()); | 381 EXPECT_EQ(panel1_bounds, panel1->GetBounds()); |
| 396 | 382 |
| 397 // Start resizing panel3, and close it in the process. | 383 // Start resizing panel3, and close it in the process. |
| 398 // Resize should abort, panel1 will not be affected. | 384 // Resize should abort, panel1 will not be affected. |
| 399 mouse_location = panel3_bounds.origin() + | 385 mouse_location = panel3_bounds.origin() + |
| 400 gfx::Vector2d(panel3_bounds.width() - 1, panel3_bounds.height() - 2); | 386 gfx::Vector2d(panel3_bounds.width() - 1, panel3_bounds.height() - 2); |
| 401 panel_manager->StartResizingByMouse(panel3, mouse_location, | 387 panel_manager->StartResizingByMouse(panel3, mouse_location, HTBOTTOMRIGHT); |
| 402 panel::RESIZE_BOTTOM_RIGHT); | |
| 403 mouse_location.Offset(7, -12); | 388 mouse_location.Offset(7, -12); |
| 404 panel_manager->ResizeByMouse(mouse_location); | 389 panel_manager->ResizeByMouse(mouse_location); |
| 405 | 390 |
| 406 panel3_bounds.set_size(gfx::Size(panel3_bounds.width() + 7, | 391 panel3_bounds.set_size(gfx::Size(panel3_bounds.width() + 7, |
| 407 panel3_bounds.height() - 12)); | 392 panel3_bounds.height() - 12)); |
| 408 EXPECT_EQ(panel3_bounds, panel3->GetBounds()); | 393 EXPECT_EQ(panel3_bounds, panel3->GetBounds()); |
| 409 | 394 |
| 410 CloseWindowAndWait(panel3); | 395 CloseWindowAndWait(panel3); |
| 411 EXPECT_EQ(1, detached_collection->num_panels()); | 396 EXPECT_EQ(1, detached_collection->num_panels()); |
| 412 // Since we closed the panel we were resizing, we should be out of the | 397 // Since we closed the panel we were resizing, we should be out of the |
| (...skipping 20 matching lines...) Expand all Loading... |
| 433 | 418 |
| 434 EXPECT_EQ(panel::RESIZABLE_ALL, panel->CanResizeByMouse()); | 419 EXPECT_EQ(panel::RESIZABLE_ALL, panel->CanResizeByMouse()); |
| 435 | 420 |
| 436 gfx::Rect original_bounds = panel->GetBounds(); | 421 gfx::Rect original_bounds = panel->GetBounds(); |
| 437 | 422 |
| 438 // Resizing the panel, then cancelling should return it to the original state. | 423 // Resizing the panel, then cancelling should return it to the original state. |
| 439 // Try resizing by the top right side. | 424 // Try resizing by the top right side. |
| 440 gfx::Rect bounds = panel->GetBounds(); | 425 gfx::Rect bounds = panel->GetBounds(); |
| 441 gfx::Point mouse_location = bounds.origin() + | 426 gfx::Point mouse_location = bounds.origin() + |
| 442 gfx::Vector2d(bounds.width() - 1, 1); | 427 gfx::Vector2d(bounds.width() - 1, 1); |
| 443 panel_manager->StartResizingByMouse(panel, mouse_location, | 428 panel_manager->StartResizingByMouse(panel, mouse_location, HTTOPRIGHT); |
| 444 panel::RESIZE_TOP_RIGHT); | |
| 445 mouse_location.Offset(5, 25); | 429 mouse_location.Offset(5, 25); |
| 446 panel_manager->ResizeByMouse(mouse_location); | 430 panel_manager->ResizeByMouse(mouse_location); |
| 447 | 431 |
| 448 bounds.set_size(gfx::Size(bounds.width() + 5, bounds.height() - 25)); | 432 bounds.set_size(gfx::Size(bounds.width() + 5, bounds.height() - 25)); |
| 449 bounds.Offset(0, 25); | 433 bounds.Offset(0, 25); |
| 450 EXPECT_EQ(bounds, panel->GetBounds()); | 434 EXPECT_EQ(bounds, panel->GetBounds()); |
| 451 | 435 |
| 452 panel_manager->EndResizingByMouse(true); | 436 panel_manager->EndResizingByMouse(true); |
| 453 EXPECT_EQ(original_bounds, panel->GetBounds()); | 437 EXPECT_EQ(original_bounds, panel->GetBounds()); |
| 454 | 438 |
| 455 // Try resizing by the bottom left side. | 439 // Try resizing by the bottom left side. |
| 456 bounds = panel->GetBounds(); | 440 bounds = panel->GetBounds(); |
| 457 mouse_location = bounds.origin() + gfx::Vector2d(1, bounds.height() - 1); | 441 mouse_location = bounds.origin() + gfx::Vector2d(1, bounds.height() - 1); |
| 458 panel_manager->StartResizingByMouse(panel, mouse_location, | 442 panel_manager->StartResizingByMouse(panel, mouse_location, HTBOTTOMLEFT); |
| 459 panel::RESIZE_BOTTOM_LEFT); | |
| 460 mouse_location.Offset(-10, 15); | 443 mouse_location.Offset(-10, 15); |
| 461 panel_manager->ResizeByMouse(mouse_location); | 444 panel_manager->ResizeByMouse(mouse_location); |
| 462 | 445 |
| 463 bounds.set_size(gfx::Size(bounds.width() + 10, bounds.height() + 15)); | 446 bounds.set_size(gfx::Size(bounds.width() + 10, bounds.height() + 15)); |
| 464 bounds.Offset(-10, 0); | 447 bounds.Offset(-10, 0); |
| 465 EXPECT_EQ(bounds, panel->GetBounds()); | 448 EXPECT_EQ(bounds, panel->GetBounds()); |
| 466 | 449 |
| 467 panel_manager->EndResizingByMouse(true); | 450 panel_manager->EndResizingByMouse(true); |
| 468 EXPECT_EQ(original_bounds, panel->GetBounds()); | 451 EXPECT_EQ(original_bounds, panel->GetBounds()); |
| 469 EXPECT_FALSE(resize_controller->IsResizing()); | 452 EXPECT_FALSE(resize_controller->IsResizing()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 485 primary_display_area, primary_work_area); | 468 primary_display_area, primary_work_area); |
| 486 | 469 |
| 487 PanelManager* panel_manager = PanelManager::GetInstance(); | 470 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 488 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); | 471 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); |
| 489 gfx::Rect bounds = panel->GetBounds(); | 472 gfx::Rect bounds = panel->GetBounds(); |
| 490 | 473 |
| 491 // Try resizing by the top left corner. | 474 // Try resizing by the top left corner. |
| 492 gfx::Point mouse_location = bounds.origin(); | 475 gfx::Point mouse_location = bounds.origin(); |
| 493 panel_manager->StartResizingByMouse(panel, | 476 panel_manager->StartResizingByMouse(panel, |
| 494 mouse_location, | 477 mouse_location, |
| 495 panel::RESIZE_TOP_LEFT); | 478 HTTOPLEFT); |
| 496 | 479 |
| 497 // Try moving the mouse outside the top of the work area. Expect that panel's | 480 // Try moving the mouse outside the top of the work area. Expect that panel's |
| 498 // top position will not exceed the top of the work area. | 481 // top position will not exceed the top of the work area. |
| 499 mouse_location = gfx::Point(250, 2); | 482 mouse_location = gfx::Point(250, 2); |
| 500 panel_manager->ResizeByMouse(mouse_location); | 483 panel_manager->ResizeByMouse(mouse_location); |
| 501 | 484 |
| 502 bounds.set_width(bounds.width() + bounds.x() - mouse_location.x()); | 485 bounds.set_width(bounds.width() + bounds.x() - mouse_location.x()); |
| 503 bounds.set_height(bounds.height() + bounds.y() - primary_work_area.y()); | 486 bounds.set_height(bounds.height() + bounds.y() - primary_work_area.y()); |
| 504 bounds.set_x(mouse_location.x()); | 487 bounds.set_x(mouse_location.x()); |
| 505 bounds.set_y(primary_work_area.y()); | 488 bounds.set_y(primary_work_area.y()); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 panel2_expected_bounds.width(), | 545 panel2_expected_bounds.width(), |
| 563 panel3_initial_bounds.height()); | 546 panel3_initial_bounds.height()); |
| 564 EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds()); | 547 EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds()); |
| 565 | 548 |
| 566 // Resize by the top-left corner of the top panel. | 549 // Resize by the top-left corner of the top panel. |
| 567 // Expect that the width of all stacked panels get increased by the same | 550 // Expect that the width of all stacked panels get increased by the same |
| 568 // amount and the top panel also expands in height. | 551 // amount and the top panel also expands in height. |
| 569 int top_resize_width = 15; | 552 int top_resize_width = 15; |
| 570 int top_resize_height = 10; | 553 int top_resize_height = 10; |
| 571 ResizePanel(panel1, | 554 ResizePanel(panel1, |
| 572 panel::RESIZE_TOP_LEFT, | 555 HTTOPLEFT, |
| 573 gfx::Vector2d(-top_resize_width, -top_resize_height)); | 556 gfx::Vector2d(-top_resize_width, -top_resize_height)); |
| 574 | 557 |
| 575 panel1_expected_full_size.Enlarge(top_resize_width, top_resize_height); | 558 panel1_expected_full_size.Enlarge(top_resize_width, top_resize_height); |
| 576 EXPECT_EQ(panel1_expected_full_size, panel1->full_size()); | 559 EXPECT_EQ(panel1_expected_full_size, panel1->full_size()); |
| 577 panel2_expected_full_size.Enlarge(top_resize_width, 0); | 560 panel2_expected_full_size.Enlarge(top_resize_width, 0); |
| 578 EXPECT_EQ(panel2_expected_full_size, panel2->full_size()); | 561 EXPECT_EQ(panel2_expected_full_size, panel2->full_size()); |
| 579 panel3_expected_full_size.Enlarge(top_resize_width, 0); | 562 panel3_expected_full_size.Enlarge(top_resize_width, 0); |
| 580 EXPECT_EQ(panel3_expected_full_size, panel3->full_size()); | 563 EXPECT_EQ(panel3_expected_full_size, panel3->full_size()); |
| 581 | 564 |
| 582 panel1_expected_bounds.SetRect( | 565 panel1_expected_bounds.SetRect( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 593 panel3_expected_bounds.set_width( | 576 panel3_expected_bounds.set_width( |
| 594 panel3_expected_bounds.width() + top_resize_width); | 577 panel3_expected_bounds.width() + top_resize_width); |
| 595 EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds()); | 578 EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds()); |
| 596 | 579 |
| 597 // Resize by the bottom-right corner of the bottom panel. | 580 // Resize by the bottom-right corner of the bottom panel. |
| 598 // Expect that the width of all stacked panels get increased by the same | 581 // Expect that the width of all stacked panels get increased by the same |
| 599 // amount and the bottom panel also shrinks in height. | 582 // amount and the bottom panel also shrinks in height. |
| 600 int bottom_resize_width = 12; | 583 int bottom_resize_width = 12; |
| 601 int bottom_resize_height = 8; | 584 int bottom_resize_height = 8; |
| 602 ResizePanel(panel3, | 585 ResizePanel(panel3, |
| 603 panel::RESIZE_BOTTOM_RIGHT, | 586 HTBOTTOMRIGHT, |
| 604 gfx::Vector2d(-bottom_resize_width, -bottom_resize_height)); | 587 gfx::Vector2d(-bottom_resize_width, -bottom_resize_height)); |
| 605 | 588 |
| 606 panel1_expected_full_size.Enlarge(-bottom_resize_width, 0); | 589 panel1_expected_full_size.Enlarge(-bottom_resize_width, 0); |
| 607 EXPECT_EQ(panel1_expected_full_size, panel1->full_size()); | 590 EXPECT_EQ(panel1_expected_full_size, panel1->full_size()); |
| 608 panel2_expected_full_size.Enlarge(-bottom_resize_width, 0); | 591 panel2_expected_full_size.Enlarge(-bottom_resize_width, 0); |
| 609 EXPECT_EQ(panel2_expected_full_size, panel2->full_size()); | 592 EXPECT_EQ(panel2_expected_full_size, panel2->full_size()); |
| 610 panel3_expected_full_size.Enlarge(-bottom_resize_width, | 593 panel3_expected_full_size.Enlarge(-bottom_resize_width, |
| 611 -bottom_resize_height); | 594 -bottom_resize_height); |
| 612 EXPECT_EQ(panel3_expected_full_size, panel3->full_size()); | 595 EXPECT_EQ(panel3_expected_full_size, panel3->full_size()); |
| 613 | 596 |
| 614 panel1_expected_bounds.set_width( | 597 panel1_expected_bounds.set_width( |
| 615 panel1_expected_bounds.width() - bottom_resize_width); | 598 panel1_expected_bounds.width() - bottom_resize_width); |
| 616 EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds()); | 599 EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds()); |
| 617 panel2_expected_bounds.set_width( | 600 panel2_expected_bounds.set_width( |
| 618 panel2_expected_bounds.width() - bottom_resize_width); | 601 panel2_expected_bounds.width() - bottom_resize_width); |
| 619 EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds()); | 602 EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds()); |
| 620 panel3_expected_bounds.set_width( | 603 panel3_expected_bounds.set_width( |
| 621 panel3_expected_bounds.width() - bottom_resize_width); | 604 panel3_expected_bounds.width() - bottom_resize_width); |
| 622 panel3_expected_bounds.set_height( | 605 panel3_expected_bounds.set_height( |
| 623 panel3_expected_bounds.height() - bottom_resize_height); | 606 panel3_expected_bounds.height() - bottom_resize_height); |
| 624 EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds()); | 607 EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds()); |
| 625 | 608 |
| 626 // Resize by the bottom edge of the middle panel. | 609 // Resize by the bottom edge of the middle panel. |
| 627 // Expect that the height of the middle panel increases and the height of | 610 // Expect that the height of the middle panel increases and the height of |
| 628 // the bottom panel decreases by the same amount. | 611 // the bottom panel decreases by the same amount. |
| 629 int middle_resize_height = 5; | 612 int middle_resize_height = 5; |
| 630 ResizePanel(panel2, | 613 ResizePanel(panel2, |
| 631 panel::RESIZE_BOTTOM, | 614 HTBOTTOM, |
| 632 gfx::Vector2d(0, middle_resize_height)); | 615 gfx::Vector2d(0, middle_resize_height)); |
| 633 | 616 |
| 634 EXPECT_EQ(panel1_expected_full_size, panel1->full_size()); | 617 EXPECT_EQ(panel1_expected_full_size, panel1->full_size()); |
| 635 panel2_expected_full_size.Enlarge(0, middle_resize_height); | 618 panel2_expected_full_size.Enlarge(0, middle_resize_height); |
| 636 EXPECT_EQ(panel2_expected_full_size, panel2->full_size()); | 619 EXPECT_EQ(panel2_expected_full_size, panel2->full_size()); |
| 637 panel3_expected_full_size.Enlarge(0, -middle_resize_height); | 620 panel3_expected_full_size.Enlarge(0, -middle_resize_height); |
| 638 EXPECT_EQ(panel3_expected_full_size, panel3->full_size()); | 621 EXPECT_EQ(panel3_expected_full_size, panel3->full_size()); |
| 639 | 622 |
| 640 EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds()); | 623 EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds()); |
| 641 panel2_expected_bounds.set_height( | 624 panel2_expected_bounds.set_height( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 660 panel2_expected_bounds.set_height(panel2->TitleOnlyHeight()); | 643 panel2_expected_bounds.set_height(panel2->TitleOnlyHeight()); |
| 661 EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds()); | 644 EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds()); |
| 662 panel3_expected_bounds.set_y(panel2_expected_bounds.bottom()); | 645 panel3_expected_bounds.set_y(panel2_expected_bounds.bottom()); |
| 663 EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds()); | 646 EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds()); |
| 664 | 647 |
| 665 // Resize by the bottom edge of the top panel. | 648 // Resize by the bottom edge of the top panel. |
| 666 // Expect that the height of the top panel increases and the height of | 649 // Expect that the height of the top panel increases and the height of |
| 667 // the middle panel is not affected because it is collapsed. | 650 // the middle panel is not affected because it is collapsed. |
| 668 top_resize_height = 18; | 651 top_resize_height = 18; |
| 669 ResizePanel(panel1, | 652 ResizePanel(panel1, |
| 670 panel::RESIZE_BOTTOM, | 653 HTBOTTOM, |
| 671 gfx::Vector2d(0, top_resize_height)); | 654 gfx::Vector2d(0, top_resize_height)); |
| 672 | 655 |
| 673 panel1_expected_full_size.Enlarge(0, top_resize_height); | 656 panel1_expected_full_size.Enlarge(0, top_resize_height); |
| 674 EXPECT_EQ(panel1_expected_full_size, panel1->full_size()); | 657 EXPECT_EQ(panel1_expected_full_size, panel1->full_size()); |
| 675 EXPECT_EQ(panel2_expected_full_size, panel2->full_size()); | 658 EXPECT_EQ(panel2_expected_full_size, panel2->full_size()); |
| 676 EXPECT_EQ(panel3_expected_full_size, panel3->full_size()); | 659 EXPECT_EQ(panel3_expected_full_size, panel3->full_size()); |
| 677 | 660 |
| 678 panel1_expected_bounds.set_height( | 661 panel1_expected_bounds.set_height( |
| 679 panel1_expected_bounds.height() + top_resize_height); | 662 panel1_expected_bounds.height() + top_resize_height); |
| 680 EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds()); | 663 EXPECT_EQ(panel1_expected_bounds, panel1->GetBounds()); |
| 681 panel2_expected_bounds.set_y( | 664 panel2_expected_bounds.set_y( |
| 682 panel2_expected_bounds.y() + top_resize_height); | 665 panel2_expected_bounds.y() + top_resize_height); |
| 683 EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds()); | 666 EXPECT_EQ(panel2_expected_bounds, panel2->GetBounds()); |
| 684 panel3_expected_bounds.set_y( | 667 panel3_expected_bounds.set_y( |
| 685 panel3_expected_bounds.y() + top_resize_height); | 668 panel3_expected_bounds.y() + top_resize_height); |
| 686 EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds()); | 669 EXPECT_EQ(panel3_expected_bounds, panel3->GetBounds()); |
| 687 | 670 |
| 688 panel_manager->CloseAll(); | 671 panel_manager->CloseAll(); |
| 689 } | 672 } |
| 690 | 673 |
| 691 #endif | 674 #endif |
| OLD | NEW |