Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(741)

Side by Side Diff: ash/wm/workspace/workspace_window_resizer_unittest.cc

Issue 2700523004: Remove docked windows entirely in M59. (Closed)
Patch Set: Rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "ash/common/wm/workspace/workspace_window_resizer.h" 5 #include "ash/common/wm/workspace/workspace_window_resizer.h"
6 6
7 #include "ash/common/ash_switches.h"
8 #include "ash/common/shelf/shelf_constants.h" 7 #include "ash/common/shelf/shelf_constants.h"
9 #include "ash/common/shelf/wm_shelf.h" 8 #include "ash/common/shelf/wm_shelf.h"
10 #include "ash/common/wm/window_positioning_utils.h" 9 #include "ash/common/wm/window_positioning_utils.h"
11 #include "ash/common/wm/window_state.h" 10 #include "ash/common/wm/window_state.h"
12 #include "ash/common/wm/wm_event.h" 11 #include "ash/common/wm/wm_event.h"
13 #include "ash/common/wm/workspace/phantom_window_controller.h" 12 #include "ash/common/wm/workspace/phantom_window_controller.h"
14 #include "ash/common/wm/workspace_controller.h" 13 #include "ash/common/wm/workspace_controller.h"
15 #include "ash/common/wm_shell.h" 14 #include "ash/common/wm_shell.h"
16 #include "ash/common/wm_window.h" 15 #include "ash/common/wm_window.h"
17 #include "ash/public/cpp/shell_window_ids.h" 16 #include "ash/public/cpp/shell_window_ids.h"
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 535
537 resizer->RevertDrag(); 536 resizer->RevertDrag();
538 } 537 }
539 538
540 // Assertions around dragging to the left/right edge of the screen. 539 // Assertions around dragging to the left/right edge of the screen.
541 TEST_F(WorkspaceWindowResizerTest, Edge) { 540 TEST_F(WorkspaceWindowResizerTest, Edge) {
542 // Resize host window to force insets update. 541 // Resize host window to force insets update.
543 UpdateDisplay("800x700"); 542 UpdateDisplay("800x700");
544 // TODO(varkha): Insets are reset after every drag because of 543 // TODO(varkha): Insets are reset after every drag because of
545 // http://crbug.com/292238. 544 // http://crbug.com/292238.
546 // Window is wide enough not to get docked right away.
547 window_->SetBounds(gfx::Rect(20, 30, 400, 60)); 545 window_->SetBounds(gfx::Rect(20, 30, 400, 60));
548 window_->SetProperty(aura::client::kResizeBehaviorKey, 546 window_->SetProperty(aura::client::kResizeBehaviorKey,
549 ui::mojom::kResizeBehaviorCanResize | 547 ui::mojom::kResizeBehaviorCanResize |
550 ui::mojom::kResizeBehaviorCanMaximize); 548 ui::mojom::kResizeBehaviorCanMaximize);
551 wm::WindowState* window_state = wm::GetWindowState(window_.get()); 549 wm::WindowState* window_state = wm::GetWindowState(window_.get());
552 550
553 { 551 {
554 gfx::Rect expected_bounds_in_parent( 552 gfx::Rect expected_bounds_in_parent(
555 wm::GetDefaultLeftSnappedWindowBoundsInParent( 553 wm::GetDefaultLeftSnappedWindowBoundsInParent(
556 WmWindow::Get(window_.get()))); 554 WmWindow::Get(window_.get())));
(...skipping 28 matching lines...) Expand all
585 window_state->GetRestoreBoundsInScreen().ToString()); 583 window_state->GetRestoreBoundsInScreen().ToString());
586 } 584 }
587 585
588 // Restore the window to clear snapped state. 586 // Restore the window to clear snapped state.
589 window_state->Restore(); 587 window_state->Restore();
590 588
591 // Test if the restore bounds is correct in multiple displays. 589 // Test if the restore bounds is correct in multiple displays.
592 UpdateDisplay("800x600,500x600"); 590 UpdateDisplay("800x600,500x600");
593 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 591 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
594 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 592 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
595 // Window is wide enough not to get docked right away.
596 window_->SetBoundsInScreen(gfx::Rect(800, 10, 400, 60), 593 window_->SetBoundsInScreen(gfx::Rect(800, 10, 400, 60),
597 GetSecondaryDisplay()); 594 GetSecondaryDisplay());
598 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 595 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
599 { 596 {
600 EXPECT_EQ("800,10 400x60", window_->GetBoundsInScreen().ToString()); 597 EXPECT_EQ("800,10 400x60", window_->GetBoundsInScreen().ToString());
601 598
602 std::unique_ptr<WindowResizer> resizer( 599 std::unique_ptr<WindowResizer> resizer(
603 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); 600 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
604 ASSERT_TRUE(resizer.get()); 601 ASSERT_TRUE(resizer.get());
605 resizer->Drag(CalculateDragPoint(*resizer, 499, 0), 0); 602 resizer->Drag(CalculateDragPoint(*resizer, 499, 0), 0);
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 EXPECT_EQ(401, window_->bounds().width()); 1484 EXPECT_EQ(401, window_->bounds().width());
1488 EXPECT_EQ(302, window_->bounds().height()); 1485 EXPECT_EQ(302, window_->bounds().height());
1489 } 1486 }
1490 1487
1491 // Test that a window with a specified max size can't be snapped. 1488 // Test that a window with a specified max size can't be snapped.
1492 TEST_F(WorkspaceWindowResizerTest, PhantomSnapMaxSize) { 1489 TEST_F(WorkspaceWindowResizerTest, PhantomSnapMaxSize) {
1493 // Make the window snappable by making it resizable and maximizable. 1490 // Make the window snappable by making it resizable and maximizable.
1494 window_->SetProperty(aura::client::kResizeBehaviorKey, 1491 window_->SetProperty(aura::client::kResizeBehaviorKey,
1495 ui::mojom::kResizeBehaviorCanResize | 1492 ui::mojom::kResizeBehaviorCanResize |
1496 ui::mojom::kResizeBehaviorCanMaximize); 1493 ui::mojom::kResizeBehaviorCanMaximize);
1497
1498 // Enable docking for this test.
1499 base::CommandLine::ForCurrentProcess()->AppendSwitch(
1500 ash::switches::kAshEnableDockedWindows);
1501
1502 { 1494 {
1503 // With max size not set we get a phantom window controller for dragging off 1495 // With max size not set we get a phantom window controller for dragging off
1504 // the right hand side. 1496 // the right hand side.
1505 // Make the window wider than maximum docked width.
1506 window_->SetBounds(gfx::Rect(0, 0, 400, 200));
1507
1508 std::unique_ptr<WindowResizer> resizer( 1497 std::unique_ptr<WindowResizer> resizer(
1509 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); 1498 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
1510 EXPECT_FALSE(snap_phantom_window_controller()); 1499 EXPECT_FALSE(snap_phantom_window_controller());
1511 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0); 1500 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0);
1512 EXPECT_TRUE(snap_phantom_window_controller()); 1501 EXPECT_TRUE(snap_phantom_window_controller());
1513 resizer->RevertDrag(); 1502 resizer->RevertDrag();
1514 } 1503 }
1515 { 1504 {
1516 // With max size defined, we get no phantom window for snapping but we still 1505 // With max size defined, we get no phantom window for snapping.
1517 // get a phantom window (docking guide).
1518 window_->SetBounds(gfx::Rect(0, 0, 400, 200)); 1506 window_->SetBounds(gfx::Rect(0, 0, 400, 200));
1519 delegate_.set_max_size(gfx::Size(400, 200)); 1507 delegate_.set_max_size(gfx::Size(400, 200));
1520 1508
1521 std::unique_ptr<WindowResizer> resizer( 1509 std::unique_ptr<WindowResizer> resizer(
1522 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); 1510 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
1523 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0); 1511 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0);
1524 EXPECT_TRUE(snap_phantom_window_controller()); 1512 EXPECT_FALSE(snap_phantom_window_controller());
1525 resizer->RevertDrag(); 1513 resizer->RevertDrag();
1526 } 1514 }
1527 { 1515 {
1528 // With max size defined, we get no phantom window for snapping. 1516 // With max size defined, we get no phantom window for snapping.
1529 window_->SetBounds(gfx::Rect(0, 0, 400, 200)); 1517 window_->SetBounds(gfx::Rect(0, 0, 400, 200));
1530 delegate_.set_max_size(gfx::Size(400, 200)); 1518 delegate_.set_max_size(gfx::Size(400, 200));
1531 // With min size defined, we get no phantom window for docking.
1532 delegate_.set_min_size(gfx::Size(400, 200));
1533 1519
1534 std::unique_ptr<WindowResizer> resizer( 1520 std::unique_ptr<WindowResizer> resizer(
1535 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); 1521 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
1536 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0); 1522 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0);
1537 EXPECT_FALSE(snap_phantom_window_controller()); 1523 EXPECT_FALSE(snap_phantom_window_controller());
1538 resizer->RevertDrag(); 1524 resizer->RevertDrag();
1539 } 1525 }
1540 } 1526 }
1541 1527
1542 TEST_F(WorkspaceWindowResizerTest, DontRewardRightmostWindowForOverflows) { 1528 TEST_F(WorkspaceWindowResizerTest, DontRewardRightmostWindowForOverflows) {
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
1879 touch_resize_window_->bounds().ToString()); 1865 touch_resize_window_->bounds().ToString());
1880 // Drag even more to snap to the edge. 1866 // Drag even more to snap to the edge.
1881 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), 1867 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40),
1882 gfx::Point(400, kRootHeight - 25), 1868 gfx::Point(400, kRootHeight - 25),
1883 base::TimeDelta::FromMilliseconds(10), 5); 1869 base::TimeDelta::FromMilliseconds(10), 5);
1884 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), 1870 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(),
1885 touch_resize_window_->bounds().ToString()); 1871 touch_resize_window_->bounds().ToString());
1886 } 1872 }
1887 1873
1888 } // namespace ash 1874 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/toplevel_window_event_handler_unittest.cc ('k') | ash/wm/workspace_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698