| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ash/wm/dock/docked_window_layout_manager.h" | 5 #include "ash/wm/dock/docked_window_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/shelf/shelf.h" | 9 #include "ash/shelf/shelf.h" |
| 10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "base/strings/string_number_conversions.h" | 28 #include "base/strings/string_number_conversions.h" |
| 29 #include "ui/aura/client/aura_constants.h" | 29 #include "ui/aura/client/aura_constants.h" |
| 30 #include "ui/aura/test/test_window_delegate.h" | 30 #include "ui/aura/test/test_window_delegate.h" |
| 31 #include "ui/aura/window.h" | 31 #include "ui/aura/window.h" |
| 32 #include "ui/aura/window_event_dispatcher.h" | 32 #include "ui/aura/window_event_dispatcher.h" |
| 33 #include "ui/base/hit_test.h" | 33 #include "ui/base/hit_test.h" |
| 34 #include "ui/gfx/screen.h" | 34 #include "ui/gfx/screen.h" |
| 35 #include "ui/views/widget/widget.h" | 35 #include "ui/views/widget/widget.h" |
| 36 | 36 |
| 37 namespace ash { | 37 namespace ash { |
| 38 namespace internal { | |
| 39 | 38 |
| 40 class DockedWindowLayoutManagerTest | 39 class DockedWindowLayoutManagerTest |
| 41 : public test::AshTestBase, | 40 : public test::AshTestBase, |
| 42 public testing::WithParamInterface<ui::wm::WindowType> { | 41 public testing::WithParamInterface<ui::wm::WindowType> { |
| 43 public: | 42 public: |
| 44 DockedWindowLayoutManagerTest() : window_type_(GetParam()) {} | 43 DockedWindowLayoutManagerTest() : window_type_(GetParam()) {} |
| 45 virtual ~DockedWindowLayoutManagerTest() {} | 44 virtual ~DockedWindowLayoutManagerTest() {} |
| 46 | 45 |
| 47 virtual void SetUp() OVERRIDE { | 46 virtual void SetUp() OVERRIDE { |
| 48 AshTestBase::SetUp(); | 47 AshTestBase::SetUp(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 PanelLayoutManager* manager = | 93 PanelLayoutManager* manager = |
| 95 static_cast<PanelLayoutManager*>(GetPanelContainer(window)-> | 94 static_cast<PanelLayoutManager*>(GetPanelContainer(window)-> |
| 96 layout_manager()); | 95 layout_manager()); |
| 97 manager->Relayout(); | 96 manager->Relayout(); |
| 98 } | 97 } |
| 99 return window; | 98 return window; |
| 100 } | 99 } |
| 101 | 100 |
| 102 aura::Window* GetPanelContainer(aura::Window* panel) { | 101 aura::Window* GetPanelContainer(aura::Window* panel) { |
| 103 return Shell::GetContainer(panel->GetRootWindow(), | 102 return Shell::GetContainer(panel->GetRootWindow(), |
| 104 internal::kShellWindowId_PanelContainer); | 103 kShellWindowId_PanelContainer); |
| 105 } | 104 } |
| 106 | 105 |
| 107 static WindowResizer* CreateSomeWindowResizer( | 106 static WindowResizer* CreateSomeWindowResizer( |
| 108 aura::Window* window, | 107 aura::Window* window, |
| 109 const gfx::Point& point_in_parent, | 108 const gfx::Point& point_in_parent, |
| 110 int window_component) { | 109 int window_component) { |
| 111 return CreateWindowResizer( | 110 return CreateWindowResizer( |
| 112 window, | 111 window, |
| 113 point_in_parent, | 112 point_in_parent, |
| 114 window_component, | 113 window_component, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 142 resizer_->RevertDrag(); | 141 resizer_->RevertDrag(); |
| 143 resizer_.reset(); | 142 resizer_.reset(); |
| 144 } | 143 } |
| 145 | 144 |
| 146 // Panels are parented by panel container during drags. | 145 // Panels are parented by panel container during drags. |
| 147 // Docked windows are parented by dock container during drags. | 146 // Docked windows are parented by dock container during drags. |
| 148 // All other windows that we are testing here have default container as a | 147 // All other windows that we are testing here have default container as a |
| 149 // parent. | 148 // parent. |
| 150 int CorrectContainerIdDuringDrag() { | 149 int CorrectContainerIdDuringDrag() { |
| 151 if (window_type_ == ui::wm::WINDOW_TYPE_PANEL) | 150 if (window_type_ == ui::wm::WINDOW_TYPE_PANEL) |
| 152 return internal::kShellWindowId_PanelContainer; | 151 return kShellWindowId_PanelContainer; |
| 153 return internal::kShellWindowId_DockedContainer; | 152 return kShellWindowId_DockedContainer; |
| 154 } | 153 } |
| 155 | 154 |
| 156 // Test dragging the window vertically (to detach if it is a panel) and then | 155 // Test dragging the window vertically (to detach if it is a panel) and then |
| 157 // horizontally to the edge with an added offset from the edge of |dx|. | 156 // horizontally to the edge with an added offset from the edge of |dx|. |
| 158 void DragRelativeToEdge(DockedEdge edge, aura::Window* window, int dx) { | 157 void DragRelativeToEdge(DockedEdge edge, aura::Window* window, int dx) { |
| 159 DragVerticallyAndRelativeToEdge( | 158 DragVerticallyAndRelativeToEdge( |
| 160 edge, | 159 edge, |
| 161 window, | 160 window, |
| 162 dx, | 161 dx, |
| 163 window_type_ == ui::wm::WINDOW_TYPE_PANEL ? -100 : 20); | 162 window_type_ == ui::wm::WINDOW_TYPE_PANEL ? -100 : 20); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 dx += work_area.x() - initial_location_in_screen.x(); | 194 dx += work_area.x() - initial_location_in_screen.x(); |
| 196 else if (edge == DOCKED_EDGE_RIGHT) | 195 else if (edge == DOCKED_EDGE_RIGHT) |
| 197 dx += work_area.right() - 1 - initial_location_in_screen.x(); | 196 dx += work_area.right() - 1 - initial_location_in_screen.x(); |
| 198 DragMove(dx, dy); | 197 DragMove(dx, dy); |
| 199 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); | 198 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); |
| 200 // Release the mouse and the panel should be attached to the dock. | 199 // Release the mouse and the panel should be attached to the dock. |
| 201 DragEnd(); | 200 DragEnd(); |
| 202 | 201 |
| 203 // x-coordinate can get adjusted by snapping or sticking. | 202 // x-coordinate can get adjusted by snapping or sticking. |
| 204 // y-coordinate could be changed by possible automatic layout if docked. | 203 // y-coordinate could be changed by possible automatic layout if docked. |
| 205 if (window->parent()->id() != internal::kShellWindowId_DockedContainer && | 204 if (window->parent()->id() != kShellWindowId_DockedContainer && |
| 206 !wm::GetWindowState(window)->HasRestoreBounds()) { | 205 !wm::GetWindowState(window)->HasRestoreBounds()) { |
| 207 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y()); | 206 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y()); |
| 208 } | 207 } |
| 209 } | 208 } |
| 210 | 209 |
| 211 private: | 210 private: |
| 212 scoped_ptr<WindowResizer> resizer_; | 211 scoped_ptr<WindowResizer> resizer_; |
| 213 scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_; | 212 scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_; |
| 214 ui::wm::WindowType window_type_; | 213 ui::wm::WindowType window_type_; |
| 215 | 214 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 227 | 226 |
| 228 gfx::Rect bounds(0, 0, 201, 201); | 227 gfx::Rect bounds(0, 0, 201, 201); |
| 229 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 228 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
| 230 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 229 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
| 231 | 230 |
| 232 // The window should be attached and docked at the right edge. | 231 // The window should be attached and docked at the right edge. |
| 233 // Its width should shrink or grow to ideal width. | 232 // Its width should shrink or grow to ideal width. |
| 234 EXPECT_EQ(window->GetRootWindow()->bounds().right(), | 233 EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
| 235 window->GetBoundsInScreen().right()); | 234 window->GetBoundsInScreen().right()); |
| 236 EXPECT_EQ(ideal_width(), window->bounds().width()); | 235 EXPECT_EQ(ideal_width(), window->bounds().width()); |
| 237 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 236 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
| 238 } | 237 } |
| 239 | 238 |
| 240 // Tests that with a window docked on the left the auto-placing logic in | 239 // Tests that with a window docked on the left the auto-placing logic in |
| 241 // RearrangeVisibleWindowOnShow places windows flush with work area edges. | 240 // RearrangeVisibleWindowOnShow places windows flush with work area edges. |
| 242 TEST_P(DockedWindowLayoutManagerTest, AutoPlacingLeft) { | 241 TEST_P(DockedWindowLayoutManagerTest, AutoPlacingLeft) { |
| 243 if (!SupportsHostWindowResize()) | 242 if (!SupportsHostWindowResize()) |
| 244 return; | 243 return; |
| 245 | 244 |
| 246 gfx::Rect bounds(0, 0, 201, 201); | 245 gfx::Rect bounds(0, 0, 201, 201); |
| 247 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 246 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
| 248 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 0); | 247 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 0); |
| 249 | 248 |
| 250 // The window should be attached and snapped to the right side of the screen. | 249 // The window should be attached and snapped to the right side of the screen. |
| 251 EXPECT_EQ(window->GetRootWindow()->bounds().x(), | 250 EXPECT_EQ(window->GetRootWindow()->bounds().x(), |
| 252 window->GetBoundsInScreen().x()); | 251 window->GetBoundsInScreen().x()); |
| 253 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 252 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
| 254 | 253 |
| 255 DockedWindowLayoutManager* manager = static_cast<DockedWindowLayoutManager*>( | 254 DockedWindowLayoutManager* manager = static_cast<DockedWindowLayoutManager*>( |
| 256 window->parent()->layout_manager()); | 255 window->parent()->layout_manager()); |
| 257 | 256 |
| 258 // Create two additional windows and test their auto-placement | 257 // Create two additional windows and test their auto-placement |
| 259 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 258 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
| 260 gfx::Rect desktop_area = window1->parent()->bounds(); | 259 gfx::Rect desktop_area = window1->parent()->bounds(); |
| 261 wm::GetWindowState(window1.get())->set_window_position_managed(true); | 260 wm::GetWindowState(window1.get())->set_window_position_managed(true); |
| 262 window1->Hide(); | 261 window1->Hide(); |
| 263 window1->SetBounds(gfx::Rect(250, 32, 231, 320)); | 262 window1->SetBounds(gfx::Rect(250, 32, 231, 320)); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 293 if (!SupportsHostWindowResize()) | 292 if (!SupportsHostWindowResize()) |
| 294 return; | 293 return; |
| 295 | 294 |
| 296 gfx::Rect bounds(0, 0, 201, 201); | 295 gfx::Rect bounds(0, 0, 201, 201); |
| 297 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 296 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
| 298 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 297 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
| 299 | 298 |
| 300 // The window should be attached and snapped to the right side of the screen. | 299 // The window should be attached and snapped to the right side of the screen. |
| 301 EXPECT_EQ(window->GetRootWindow()->bounds().right(), | 300 EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
| 302 window->GetBoundsInScreen().right()); | 301 window->GetBoundsInScreen().right()); |
| 303 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 302 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
| 304 | 303 |
| 305 DockedWindowLayoutManager* manager = static_cast<DockedWindowLayoutManager*>( | 304 DockedWindowLayoutManager* manager = static_cast<DockedWindowLayoutManager*>( |
| 306 window->parent()->layout_manager()); | 305 window->parent()->layout_manager()); |
| 307 | 306 |
| 308 // Create two additional windows and test their auto-placement | 307 // Create two additional windows and test their auto-placement |
| 309 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 308 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
| 310 gfx::Rect desktop_area = window1->parent()->bounds(); | 309 gfx::Rect desktop_area = window1->parent()->bounds(); |
| 311 wm::GetWindowState(window1.get())->set_window_position_managed(true); | 310 wm::GetWindowState(window1.get())->set_window_position_managed(true); |
| 312 window1->Hide(); | 311 window1->Hide(); |
| 313 window1->SetBounds(gfx::Rect(16, 32, 231, 320)); | 312 window1->SetBounds(gfx::Rect(16, 32, 231, 320)); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 UpdateDisplay("600x600,600x600"); | 346 UpdateDisplay("600x600,600x600"); |
| 348 | 347 |
| 349 gfx::Rect bounds(600, 0, 201, 201); | 348 gfx::Rect bounds(600, 0, 201, 201); |
| 350 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 349 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
| 351 // Drag pointer to the right edge of the second screen. | 350 // Drag pointer to the right edge of the second screen. |
| 352 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 351 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
| 353 | 352 |
| 354 // The window should be attached and snapped to the right side of the screen. | 353 // The window should be attached and snapped to the right side of the screen. |
| 355 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 354 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
| 356 window->GetBoundsInScreen().right()); | 355 window->GetBoundsInScreen().right()); |
| 357 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 356 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
| 358 | 357 |
| 359 DockedWindowLayoutManager* manager = static_cast<DockedWindowLayoutManager*>( | 358 DockedWindowLayoutManager* manager = static_cast<DockedWindowLayoutManager*>( |
| 360 window->parent()->layout_manager()); | 359 window->parent()->layout_manager()); |
| 361 | 360 |
| 362 // Create two additional windows and test their auto-placement | 361 // Create two additional windows and test their auto-placement |
| 363 bounds = gfx::Rect(616, 32, 231, 320); | 362 bounds = gfx::Rect(616, 32, 231, 320); |
| 364 scoped_ptr<aura::Window> window1( | 363 scoped_ptr<aura::Window> window1( |
| 365 CreateTestWindowInShellWithDelegate(NULL, 1, bounds)); | 364 CreateTestWindowInShellWithDelegate(NULL, 1, bounds)); |
| 366 gfx::Rect desktop_area = window1->parent()->bounds(); | 365 gfx::Rect desktop_area = window1->parent()->bounds(); |
| 367 wm::GetWindowState(window1.get())->set_window_position_managed(true); | 366 wm::GetWindowState(window1.get())->set_window_position_managed(true); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 398 return; | 397 return; |
| 399 | 398 |
| 400 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 399 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
| 401 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 202))); | 400 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 202))); |
| 402 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 401 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
| 403 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 300); | 402 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 300); |
| 404 | 403 |
| 405 // The windows should be attached and snapped to the right side of the screen. | 404 // The windows should be attached and snapped to the right side of the screen. |
| 406 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 405 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
| 407 w1->GetBoundsInScreen().right()); | 406 w1->GetBoundsInScreen().right()); |
| 408 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 407 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 409 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), | 408 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
| 410 w2->GetBoundsInScreen().right()); | 409 w2->GetBoundsInScreen().right()); |
| 411 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); | 410 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
| 412 | 411 |
| 413 // Test that the gaps differ at most by a single pixel. | 412 // Test that the gaps differ at most by a single pixel. |
| 414 gfx::Rect work_area = | 413 gfx::Rect work_area = |
| 415 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); | 414 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); |
| 416 int gap1 = w1->GetBoundsInScreen().y(); | 415 int gap1 = w1->GetBoundsInScreen().y(); |
| 417 int gap2 = w2->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom(); | 416 int gap2 = w2->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom(); |
| 418 int gap3 = work_area.bottom() - w2->GetBoundsInScreen().bottom(); | 417 int gap3 = work_area.bottom() - w2->GetBoundsInScreen().bottom(); |
| 419 EXPECT_EQ(0, gap1); | 418 EXPECT_EQ(0, gap1); |
| 420 EXPECT_NEAR(gap2, min_dock_gap(), 1); | 419 EXPECT_NEAR(gap2, min_dock_gap(), 1); |
| 421 EXPECT_EQ(0, gap3); | 420 EXPECT_EQ(0, gap3); |
| 422 } | 421 } |
| 423 | 422 |
| 424 // Adds two non-overlapping windows and tests layout after a drag. | 423 // Adds two non-overlapping windows and tests layout after a drag. |
| 425 TEST_P(DockedWindowLayoutManagerTest, TwoWindowsDragging) { | 424 TEST_P(DockedWindowLayoutManagerTest, TwoWindowsDragging) { |
| 426 if (!SupportsHostWindowResize()) | 425 if (!SupportsHostWindowResize()) |
| 427 return; | 426 return; |
| 428 | 427 |
| 429 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 428 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
| 430 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 202))); | 429 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 202))); |
| 431 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 430 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
| 432 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 300); | 431 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 300); |
| 433 | 432 |
| 434 // The windows should be attached and snapped to the right side of the screen. | 433 // The windows should be attached and snapped to the right side of the screen. |
| 435 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 434 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
| 436 w1->GetBoundsInScreen().right()); | 435 w1->GetBoundsInScreen().right()); |
| 437 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 436 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 438 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), | 437 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
| 439 w2->GetBoundsInScreen().right()); | 438 w2->GetBoundsInScreen().right()); |
| 440 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); | 439 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
| 441 | 440 |
| 442 // Drag w2 above w1. | 441 // Drag w2 above w1. |
| 443 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(w2.get(), 0, 20)); | 442 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(w2.get(), 0, 20)); |
| 444 DragMove(0, -w2->bounds().height() / 2 - min_dock_gap() - 1); | 443 DragMove(0, -w2->bounds().height() / 2 - min_dock_gap() - 1); |
| 445 DragEnd(); | 444 DragEnd(); |
| 446 | 445 |
| 447 // Test the new windows order and that the gaps differ at most by a pixel. | 446 // Test the new windows order and that the gaps differ at most by a pixel. |
| 448 gfx::Rect work_area = | 447 gfx::Rect work_area = |
| 449 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); | 448 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); |
| 450 int gap1 = w2->GetBoundsInScreen().y() - work_area.y(); | 449 int gap1 = w2->GetBoundsInScreen().y() - work_area.y(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 464 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 310))); | 463 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 310))); |
| 465 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 464 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
| 466 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 310))); | 465 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 310))); |
| 467 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 500); | 466 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 500); |
| 468 scoped_ptr<aura::Window> w3(CreateTestWindow(gfx::Rect(0, 0, 220, 310))); | 467 scoped_ptr<aura::Window> w3(CreateTestWindow(gfx::Rect(0, 0, 220, 310))); |
| 469 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 600); | 468 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 600); |
| 470 | 469 |
| 471 // All windows should be attached and snapped to the right side of the screen. | 470 // All windows should be attached and snapped to the right side of the screen. |
| 472 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 471 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
| 473 w1->GetBoundsInScreen().right()); | 472 w1->GetBoundsInScreen().right()); |
| 474 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 473 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 475 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), | 474 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
| 476 w2->GetBoundsInScreen().right()); | 475 w2->GetBoundsInScreen().right()); |
| 477 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); | 476 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
| 478 EXPECT_EQ(w3->GetRootWindow()->bounds().right(), | 477 EXPECT_EQ(w3->GetRootWindow()->bounds().right(), |
| 479 w3->GetBoundsInScreen().right()); | 478 w3->GetBoundsInScreen().right()); |
| 480 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w3->parent()->id()); | 479 EXPECT_EQ(kShellWindowId_DockedContainer, w3->parent()->id()); |
| 481 | 480 |
| 482 // Test that the top and bottom windows are clamped in work area and | 481 // Test that the top and bottom windows are clamped in work area and |
| 483 // that the gaps between the windows differ at most by a pixel. | 482 // that the gaps between the windows differ at most by a pixel. |
| 484 gfx::Rect work_area = | 483 gfx::Rect work_area = |
| 485 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); | 484 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); |
| 486 int gap1 = w1->GetBoundsInScreen().y() - work_area.y(); | 485 int gap1 = w1->GetBoundsInScreen().y() - work_area.y(); |
| 487 int gap2 = w2->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom(); | 486 int gap2 = w2->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom(); |
| 488 int gap3 = w3->GetBoundsInScreen().y() - w2->GetBoundsInScreen().bottom(); | 487 int gap3 = w3->GetBoundsInScreen().y() - w2->GetBoundsInScreen().bottom(); |
| 489 int gap4 = work_area.bottom() - w3->GetBoundsInScreen().bottom(); | 488 int gap4 = work_area.bottom() - w3->GetBoundsInScreen().bottom(); |
| 490 EXPECT_EQ(0, gap1); | 489 EXPECT_EQ(0, gap1); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 1000, 201, 310))); | 532 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 1000, 201, 310))); |
| 534 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 1000 + 20); | 533 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 1000 + 20); |
| 535 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 1000, 210, 310))); | 534 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 1000, 210, 310))); |
| 536 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 1000 + 500); | 535 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 1000 + 500); |
| 537 scoped_ptr<aura::Window> w3(CreateTestWindow(gfx::Rect(0, 1000, 220, 310))); | 536 scoped_ptr<aura::Window> w3(CreateTestWindow(gfx::Rect(0, 1000, 220, 310))); |
| 538 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 1000 + 600); | 537 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 1000 + 600); |
| 539 | 538 |
| 540 // All windows should be attached and snapped to the right side of the screen. | 539 // All windows should be attached and snapped to the right side of the screen. |
| 541 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 540 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
| 542 w1->GetBoundsInScreen().right()); | 541 w1->GetBoundsInScreen().right()); |
| 543 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 542 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 544 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), | 543 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
| 545 w2->GetBoundsInScreen().right()); | 544 w2->GetBoundsInScreen().right()); |
| 546 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); | 545 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
| 547 EXPECT_EQ(w3->GetRootWindow()->bounds().right(), | 546 EXPECT_EQ(w3->GetRootWindow()->bounds().right(), |
| 548 w3->GetBoundsInScreen().right()); | 547 w3->GetBoundsInScreen().right()); |
| 549 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w3->parent()->id()); | 548 EXPECT_EQ(kShellWindowId_DockedContainer, w3->parent()->id()); |
| 550 | 549 |
| 551 gfx::Rect work_area = | 550 gfx::Rect work_area = |
| 552 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); | 551 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); |
| 553 // Test that the top and bottom windows are clamped in work area and | 552 // Test that the top and bottom windows are clamped in work area and |
| 554 // that the overlaps between the windows differ at most by a pixel. | 553 // that the overlaps between the windows differ at most by a pixel. |
| 555 int gap1 = w1->GetBoundsInScreen().y() - work_area.y(); | 554 int gap1 = w1->GetBoundsInScreen().y() - work_area.y(); |
| 556 int gap2 = w2->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom(); | 555 int gap2 = w2->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom(); |
| 557 int gap3 = w3->GetBoundsInScreen().y() - w2->GetBoundsInScreen().bottom(); | 556 int gap3 = w3->GetBoundsInScreen().y() - w2->GetBoundsInScreen().bottom(); |
| 558 int gap4 = work_area.bottom() - w3->GetBoundsInScreen().bottom(); | 557 int gap4 = work_area.bottom() - w3->GetBoundsInScreen().bottom(); |
| 559 EXPECT_EQ(0, gap1); | 558 EXPECT_EQ(0, gap1); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 // Secondary drag ensures that we are testing the minimum size restriction | 677 // Secondary drag ensures that we are testing the minimum size restriction |
| 679 // and not just failure to get past the tiling step in SnapSizer. | 678 // and not just failure to get past the tiling step in SnapSizer. |
| 680 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(window.get(), | 679 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(window.get(), |
| 681 25, 5)); | 680 25, 5)); |
| 682 DragMove(150,0); | 681 DragMove(150,0); |
| 683 DragEnd(); | 682 DragEnd(); |
| 684 | 683 |
| 685 // The window should not get docked even though it is dragged past the edge. | 684 // The window should not get docked even though it is dragged past the edge. |
| 686 EXPECT_NE(window->GetRootWindow()->bounds().right(), | 685 EXPECT_NE(window->GetRootWindow()->bounds().right(), |
| 687 window->GetBoundsInScreen().right()); | 686 window->GetBoundsInScreen().right()); |
| 688 EXPECT_NE(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 687 EXPECT_NE(kShellWindowId_DockedContainer, window->parent()->id()); |
| 689 } | 688 } |
| 690 | 689 |
| 691 // Docks three windows and tests that the very first window gets minimized. | 690 // Docks three windows and tests that the very first window gets minimized. |
| 692 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsMinimize) { | 691 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsMinimize) { |
| 693 if (!SupportsHostWindowResize()) | 692 if (!SupportsHostWindowResize()) |
| 694 return; | 693 return; |
| 695 | 694 |
| 696 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 695 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
| 697 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 696 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
| 698 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 202))); | 697 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 202))); |
| 699 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 200); | 698 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 200); |
| 700 scoped_ptr<aura::Window> w3(CreateTestWindow(gfx::Rect(0, 0, 220, 204))); | 699 scoped_ptr<aura::Window> w3(CreateTestWindow(gfx::Rect(0, 0, 220, 204))); |
| 701 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 300); | 700 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 300); |
| 702 | 701 |
| 703 // The last two windows should be attached and snapped to the right edge. | 702 // The last two windows should be attached and snapped to the right edge. |
| 704 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), | 703 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
| 705 w2->GetBoundsInScreen().right()); | 704 w2->GetBoundsInScreen().right()); |
| 706 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); | 705 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
| 707 EXPECT_EQ(w3->GetRootWindow()->bounds().right(), | 706 EXPECT_EQ(w3->GetRootWindow()->bounds().right(), |
| 708 w3->GetBoundsInScreen().right()); | 707 w3->GetBoundsInScreen().right()); |
| 709 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w3->parent()->id()); | 708 EXPECT_EQ(kShellWindowId_DockedContainer, w3->parent()->id()); |
| 710 | 709 |
| 711 // The first window should get minimized but parented by the dock container. | 710 // The first window should get minimized but parented by the dock container. |
| 712 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsMinimized()); | 711 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsMinimized()); |
| 713 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsNormalStateType()); | 712 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsNormalStateType()); |
| 714 EXPECT_TRUE(wm::GetWindowState(w3.get())->IsNormalStateType()); | 713 EXPECT_TRUE(wm::GetWindowState(w3.get())->IsNormalStateType()); |
| 715 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 714 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 716 } | 715 } |
| 717 | 716 |
| 718 // Docks up to three windows and tests that they split vertical space. | 717 // Docks up to three windows and tests that they split vertical space. |
| 719 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsSplitHeightEvenly) { | 718 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsSplitHeightEvenly) { |
| 720 if (!SupportsHostWindowResize()) | 719 if (!SupportsHostWindowResize()) |
| 721 return; | 720 return; |
| 722 | 721 |
| 723 UpdateDisplay("600x1000"); | 722 UpdateDisplay("600x1000"); |
| 724 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 723 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
| 725 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 724 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
| 726 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 202))); | 725 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 202))); |
| 727 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 200); | 726 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 200); |
| 728 | 727 |
| 729 // The two windows should be attached and snapped to the right edge. | 728 // The two windows should be attached and snapped to the right edge. |
| 730 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 729 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
| 731 w1->GetBoundsInScreen().right()); | 730 w1->GetBoundsInScreen().right()); |
| 732 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 731 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 733 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), | 732 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
| 734 w2->GetBoundsInScreen().right()); | 733 w2->GetBoundsInScreen().right()); |
| 735 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); | 734 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
| 736 | 735 |
| 737 // The two windows should be same size vertically and almost 1/2 of work area. | 736 // The two windows should be same size vertically and almost 1/2 of work area. |
| 738 gfx::Rect work_area = | 737 gfx::Rect work_area = |
| 739 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); | 738 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); |
| 740 EXPECT_NEAR(w1->GetBoundsInScreen().height(), | 739 EXPECT_NEAR(w1->GetBoundsInScreen().height(), |
| 741 w2->GetBoundsInScreen().height(), | 740 w2->GetBoundsInScreen().height(), |
| 742 1); | 741 1); |
| 743 EXPECT_NEAR(work_area.height() / 2, w1->GetBoundsInScreen().height(), | 742 EXPECT_NEAR(work_area.height() / 2, w1->GetBoundsInScreen().height(), |
| 744 min_dock_gap() * 2); | 743 min_dock_gap() * 2); |
| 745 | 744 |
| 746 // Create and dock the third window. | 745 // Create and dock the third window. |
| 747 scoped_ptr<aura::Window> w3(CreateTestWindow(gfx::Rect(0, 0, 220, 204))); | 746 scoped_ptr<aura::Window> w3(CreateTestWindow(gfx::Rect(0, 0, 220, 204))); |
| 748 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 300); | 747 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 300); |
| 749 | 748 |
| 750 // All three windows should be docked and snapped to the right edge. | 749 // All three windows should be docked and snapped to the right edge. |
| 751 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 750 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 752 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); | 751 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
| 753 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w3->parent()->id()); | 752 EXPECT_EQ(kShellWindowId_DockedContainer, w3->parent()->id()); |
| 754 | 753 |
| 755 // All windows should be near same size vertically and about 1/3 of work area. | 754 // All windows should be near same size vertically and about 1/3 of work area. |
| 756 EXPECT_NEAR(w1->GetBoundsInScreen().height(), | 755 EXPECT_NEAR(w1->GetBoundsInScreen().height(), |
| 757 w2->GetBoundsInScreen().height(), | 756 w2->GetBoundsInScreen().height(), |
| 758 1); | 757 1); |
| 759 EXPECT_NEAR(w2->GetBoundsInScreen().height(), | 758 EXPECT_NEAR(w2->GetBoundsInScreen().height(), |
| 760 w3->GetBoundsInScreen().height(), | 759 w3->GetBoundsInScreen().height(), |
| 761 1); | 760 1); |
| 762 EXPECT_NEAR(work_area.height() / 3, w1->GetBoundsInScreen().height(), | 761 EXPECT_NEAR(work_area.height() / 3, w1->GetBoundsInScreen().height(), |
| 763 min_dock_gap() * 2); | 762 min_dock_gap() * 2); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 779 delegate2.set_maximum_size(gfx::Size(0, 100)); | 778 delegate2.set_maximum_size(gfx::Size(0, 100)); |
| 780 scoped_ptr<aura::Window> w2(CreateTestWindowWithDelegate( | 779 scoped_ptr<aura::Window> w2(CreateTestWindowWithDelegate( |
| 781 gfx::Rect(0, 0, 280, 90), &delegate2)); | 780 gfx::Rect(0, 0, 280, 90), &delegate2)); |
| 782 | 781 |
| 783 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 782 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
| 784 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 200); | 783 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 200); |
| 785 | 784 |
| 786 // The two windows should be attached and snapped to the right edge. | 785 // The two windows should be attached and snapped to the right edge. |
| 787 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 786 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
| 788 w1->GetBoundsInScreen().right()); | 787 w1->GetBoundsInScreen().right()); |
| 789 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 788 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 790 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), | 789 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
| 791 w2->GetBoundsInScreen().right()); | 790 w2->GetBoundsInScreen().right()); |
| 792 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); | 791 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
| 793 | 792 |
| 794 // The two windows should have their heights restricted. | 793 // The two windows should have their heights restricted. |
| 795 EXPECT_EQ(300, w1->GetBoundsInScreen().height()); | 794 EXPECT_EQ(300, w1->GetBoundsInScreen().height()); |
| 796 EXPECT_EQ(100, w2->GetBoundsInScreen().height()); | 795 EXPECT_EQ(100, w2->GetBoundsInScreen().height()); |
| 797 | 796 |
| 798 // w1 should be more than half of the work area height (even with a margin). | 797 // w1 should be more than half of the work area height (even with a margin). |
| 799 // w2 should be less than half of the work area height (even with a margin). | 798 // w2 should be less than half of the work area height (even with a margin). |
| 800 gfx::Rect work_area = | 799 gfx::Rect work_area = |
| 801 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); | 800 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); |
| 802 EXPECT_GT(w1->GetBoundsInScreen().height(), work_area.height() / 2 + 10); | 801 EXPECT_GT(w1->GetBoundsInScreen().height(), work_area.height() / 2 + 10); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 817 // Drag pointer to the right edge of the second screen. | 816 // Drag pointer to the right edge of the second screen. |
| 818 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 817 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
| 819 | 818 |
| 820 // Simulate disconnection of the secondary display. | 819 // Simulate disconnection of the secondary display. |
| 821 UpdateDisplay("600x700"); | 820 UpdateDisplay("600x700"); |
| 822 | 821 |
| 823 // The window should be still docked at the right edge. | 822 // The window should be still docked at the right edge. |
| 824 // Its height should grow to match the new work area. | 823 // Its height should grow to match the new work area. |
| 825 EXPECT_EQ(window->GetRootWindow()->bounds().right(), | 824 EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
| 826 window->GetBoundsInScreen().right()); | 825 window->GetBoundsInScreen().right()); |
| 827 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 826 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
| 828 EXPECT_EQ(ideal_width(), window->bounds().width()); | 827 EXPECT_EQ(ideal_width(), window->bounds().width()); |
| 829 gfx::Rect work_area = | 828 gfx::Rect work_area = |
| 830 Shell::GetScreen()->GetDisplayNearestWindow(window.get()).work_area(); | 829 Shell::GetScreen()->GetDisplayNearestWindow(window.get()).work_area(); |
| 831 EXPECT_EQ(work_area.height(), window->GetBoundsInScreen().height()); | 830 EXPECT_EQ(work_area.height(), window->GetBoundsInScreen().height()); |
| 832 } | 831 } |
| 833 | 832 |
| 834 // Tests run twice - on both panels and normal windows | 833 // Tests run twice - on both panels and normal windows |
| 835 INSTANTIATE_TEST_CASE_P(NormalOrPanel, | 834 INSTANTIATE_TEST_CASE_P(NormalOrPanel, |
| 836 DockedWindowLayoutManagerTest, | 835 DockedWindowLayoutManagerTest, |
| 837 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, | 836 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, |
| 838 ui::wm::WINDOW_TYPE_PANEL)); | 837 ui::wm::WINDOW_TYPE_PANEL)); |
| 839 } // namespace internal | 838 |
| 840 } // namespace ash | 839 } // namespace ash |
| OLD | NEW |