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

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

Issue 2700523004: Remove docked windows entirely in M59. (Closed)
Patch Set: oshima + mfomitchev comments 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_window.h" 14 #include "ash/common/wm_window.h"
16 #include "ash/public/cpp/shell_window_ids.h" 15 #include "ash/public/cpp/shell_window_ids.h"
17 #include "ash/screen_util.h" 16 #include "ash/screen_util.h"
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 529
531 resizer->RevertDrag(); 530 resizer->RevertDrag();
532 } 531 }
533 532
534 // Assertions around dragging to the left/right edge of the screen. 533 // Assertions around dragging to the left/right edge of the screen.
535 TEST_F(WorkspaceWindowResizerTest, Edge) { 534 TEST_F(WorkspaceWindowResizerTest, Edge) {
536 // Resize host window to force insets update. 535 // Resize host window to force insets update.
537 UpdateDisplay("800x700"); 536 UpdateDisplay("800x700");
538 // TODO(varkha): Insets are reset after every drag because of 537 // TODO(varkha): Insets are reset after every drag because of
539 // http://crbug.com/292238. 538 // http://crbug.com/292238.
540 // Window is wide enough not to get docked right away. 539 // Window is wide enough not to get docked right away.
varkha 2017/02/28 00:59:02 Do we still care about the window width?
afakhry 2017/03/09 22:28:27 I think we need to keep the bounds just to match t
541 window_->SetBounds(gfx::Rect(20, 30, 400, 60)); 540 window_->SetBounds(gfx::Rect(20, 30, 400, 60));
542 window_->SetProperty(aura::client::kResizeBehaviorKey, 541 window_->SetProperty(aura::client::kResizeBehaviorKey,
543 ui::mojom::kResizeBehaviorCanResize | 542 ui::mojom::kResizeBehaviorCanResize |
544 ui::mojom::kResizeBehaviorCanMaximize); 543 ui::mojom::kResizeBehaviorCanMaximize);
545 wm::WindowState* window_state = wm::GetWindowState(window_.get()); 544 wm::WindowState* window_state = wm::GetWindowState(window_.get());
546 545
547 { 546 {
548 gfx::Rect expected_bounds_in_parent( 547 gfx::Rect expected_bounds_in_parent(
549 wm::GetDefaultLeftSnappedWindowBoundsInParent( 548 wm::GetDefaultLeftSnappedWindowBoundsInParent(
550 WmWindow::Get(window_.get()))); 549 WmWindow::Get(window_.get())));
(...skipping 28 matching lines...) Expand all
579 window_state->GetRestoreBoundsInScreen().ToString()); 578 window_state->GetRestoreBoundsInScreen().ToString());
580 } 579 }
581 580
582 // Restore the window to clear snapped state. 581 // Restore the window to clear snapped state.
583 window_state->Restore(); 582 window_state->Restore();
584 583
585 // Test if the restore bounds is correct in multiple displays. 584 // Test if the restore bounds is correct in multiple displays.
586 UpdateDisplay("800x600,500x600"); 585 UpdateDisplay("800x600,500x600");
587 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 586 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
588 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 587 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
589 // Window is wide enough not to get docked right away. 588 // Window is wide enough not to get docked right away.
varkha 2017/02/28 00:59:03 ditto.
afakhry 2017/03/09 22:28:27 Just as above.
590 window_->SetBoundsInScreen(gfx::Rect(800, 10, 400, 60), 589 window_->SetBoundsInScreen(gfx::Rect(800, 10, 400, 60),
591 display_manager()->GetSecondaryDisplay()); 590 display_manager()->GetSecondaryDisplay());
592 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 591 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
593 { 592 {
594 EXPECT_EQ("800,10 400x60", window_->GetBoundsInScreen().ToString()); 593 EXPECT_EQ("800,10 400x60", window_->GetBoundsInScreen().ToString());
595 594
596 std::unique_ptr<WindowResizer> resizer( 595 std::unique_ptr<WindowResizer> resizer(
597 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); 596 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
598 ASSERT_TRUE(resizer.get()); 597 ASSERT_TRUE(resizer.get());
599 resizer->Drag(CalculateDragPoint(*resizer, 499, 0), 0); 598 resizer->Drag(CalculateDragPoint(*resizer, 499, 0), 0);
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 EXPECT_EQ(401, window_->bounds().width()); 1475 EXPECT_EQ(401, window_->bounds().width());
1477 EXPECT_EQ(302, window_->bounds().height()); 1476 EXPECT_EQ(302, window_->bounds().height());
1478 } 1477 }
1479 1478
1480 // Test that a window with a specified max size can't be snapped. 1479 // Test that a window with a specified max size can't be snapped.
1481 TEST_F(WorkspaceWindowResizerTest, PhantomSnapMaxSize) { 1480 TEST_F(WorkspaceWindowResizerTest, PhantomSnapMaxSize) {
1482 // Make the window snappable by making it resizable and maximizable. 1481 // Make the window snappable by making it resizable and maximizable.
1483 window_->SetProperty(aura::client::kResizeBehaviorKey, 1482 window_->SetProperty(aura::client::kResizeBehaviorKey,
1484 ui::mojom::kResizeBehaviorCanResize | 1483 ui::mojom::kResizeBehaviorCanResize |
1485 ui::mojom::kResizeBehaviorCanMaximize); 1484 ui::mojom::kResizeBehaviorCanMaximize);
1486
1487 // Enable docking for this test.
1488 base::CommandLine::ForCurrentProcess()->AppendSwitch(
1489 ash::switches::kAshEnableDockedWindows);
1490
1491 { 1485 {
1492 // With max size not set we get a phantom window controller for dragging off 1486 // With max size not set we get a phantom window controller for dragging off
1493 // the right hand side. 1487 // the right hand side.
1494 // Make the window wider than maximum docked width. 1488 // Make the window wider than maximum docked width.
varkha 2017/02/28 00:59:02 No need to refer to docking? Is this still necessa
afakhry 2017/03/09 22:28:27 Removed.
1495 window_->SetBounds(gfx::Rect(0, 0, 400, 200)); 1489 window_->SetBounds(gfx::Rect(0, 0, 400, 200));
1496 1490
1497 std::unique_ptr<WindowResizer> resizer( 1491 std::unique_ptr<WindowResizer> resizer(
1498 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); 1492 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
1499 EXPECT_FALSE(snap_phantom_window_controller()); 1493 EXPECT_FALSE(snap_phantom_window_controller());
1500 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0); 1494 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0);
1501 EXPECT_TRUE(snap_phantom_window_controller()); 1495 EXPECT_TRUE(snap_phantom_window_controller());
1502 resizer->RevertDrag(); 1496 resizer->RevertDrag();
1503 } 1497 }
1504 { 1498 {
1505 // With max size defined, we get no phantom window for snapping but we still 1499 // With max size defined, we get no phantom window for snapping.
1506 // get a phantom window (docking guide).
1507 window_->SetBounds(gfx::Rect(0, 0, 400, 200)); 1500 window_->SetBounds(gfx::Rect(0, 0, 400, 200));
1508 delegate_.set_max_size(gfx::Size(400, 200)); 1501 delegate_.set_max_size(gfx::Size(400, 200));
1509 1502
1510 std::unique_ptr<WindowResizer> resizer( 1503 std::unique_ptr<WindowResizer> resizer(
1511 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); 1504 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
1512 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0); 1505 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0);
1513 EXPECT_TRUE(snap_phantom_window_controller()); 1506 EXPECT_FALSE(snap_phantom_window_controller());
1514 resizer->RevertDrag(); 1507 resizer->RevertDrag();
1515 } 1508 }
1516 { 1509 {
1517 // With max size defined, we get no phantom window for snapping. 1510 // With max size defined, we get no phantom window for snapping.
1518 window_->SetBounds(gfx::Rect(0, 0, 400, 200)); 1511 window_->SetBounds(gfx::Rect(0, 0, 400, 200));
1519 delegate_.set_max_size(gfx::Size(400, 200)); 1512 delegate_.set_max_size(gfx::Size(400, 200));
1520 // With min size defined, we get no phantom window for docking. 1513 // With min size defined, we get no phantom window for docking.
varkha 2017/02/28 00:59:02 Is setting a minimum size still affecting this tes
afakhry 2017/03/09 22:28:27 Removed.
1521 delegate_.set_min_size(gfx::Size(400, 200)); 1514 delegate_.set_min_size(gfx::Size(400, 200));
1522 1515
1523 std::unique_ptr<WindowResizer> resizer( 1516 std::unique_ptr<WindowResizer> resizer(
1524 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); 1517 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
1525 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0); 1518 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0);
1526 EXPECT_FALSE(snap_phantom_window_controller()); 1519 EXPECT_FALSE(snap_phantom_window_controller());
1527 resizer->RevertDrag(); 1520 resizer->RevertDrag();
1528 } 1521 }
1529 } 1522 }
1530 1523
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 touch_resize_window_->bounds().ToString()); 1861 touch_resize_window_->bounds().ToString());
1869 // Drag even more to snap to the edge. 1862 // Drag even more to snap to the edge.
1870 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), 1863 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40),
1871 gfx::Point(400, kRootHeight - 25), 1864 gfx::Point(400, kRootHeight - 25),
1872 base::TimeDelta::FromMilliseconds(10), 5); 1865 base::TimeDelta::FromMilliseconds(10), 5);
1873 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), 1866 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(),
1874 touch_resize_window_->bounds().ToString()); 1867 touch_resize_window_->bounds().ToString());
1875 } 1868 }
1876 1869
1877 } // namespace ash 1870 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698