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

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

Issue 2617733002: Hide docked windows behind a flag (Closed)
Patch Set: Fix tests failed because of DCHECK Created 3 years, 11 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/aura/wm_window_aura.h" 7 #include "ash/aura/wm_window_aura.h"
8 #include "ash/common/ash_switches.h"
8 #include "ash/common/shelf/shelf_constants.h" 9 #include "ash/common/shelf/shelf_constants.h"
9 #include "ash/common/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
10 #include "ash/common/wm/window_positioning_utils.h" 11 #include "ash/common/wm/window_positioning_utils.h"
11 #include "ash/common/wm/window_state.h" 12 #include "ash/common/wm/window_state.h"
12 #include "ash/common/wm/wm_event.h" 13 #include "ash/common/wm/wm_event.h"
13 #include "ash/common/wm/workspace/phantom_window_controller.h" 14 #include "ash/common/wm/workspace/phantom_window_controller.h"
14 #include "ash/common/wm/workspace_controller.h" 15 #include "ash/common/wm/workspace_controller.h"
15 #include "ash/public/cpp/shell_window_ids.h" 16 #include "ash/public/cpp/shell_window_ids.h"
16 #include "ash/screen_util.h" 17 #include "ash/screen_util.h"
17 #include "ash/shell.h" 18 #include "ash/shell.h"
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 TEST_P(WorkspaceWindowResizerTest, CancelSnapPhantom) { 644 TEST_P(WorkspaceWindowResizerTest, CancelSnapPhantom) {
644 if (!SupportsMultipleDisplays()) 645 if (!SupportsMultipleDisplays())
645 return; 646 return;
646 647
647 UpdateDisplay("800x600,800x600"); 648 UpdateDisplay("800x600,800x600");
648 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 649 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
649 ASSERT_EQ(2U, root_windows.size()); 650 ASSERT_EQ(2U, root_windows.size());
650 651
651 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 652 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
652 display::Screen::GetScreen()->GetPrimaryDisplay()); 653 display::Screen::GetScreen()->GetPrimaryDisplay());
654
655 // Make the window snappable by making it resizable and maximizable.
656 window_->SetProperty(aura::client::kResizeBehaviorKey,
657 ui::mojom::kResizeBehaviorCanResize |
658 ui::mojom::kResizeBehaviorCanMaximize);
653 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 659 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
654 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 660 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
655 { 661 {
656 std::unique_ptr<WindowResizer> resizer( 662 std::unique_ptr<WindowResizer> resizer(
657 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); 663 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
658 ASSERT_TRUE(resizer.get()); 664 ASSERT_TRUE(resizer.get());
659 EXPECT_FALSE(snap_phantom_window_controller()); 665 EXPECT_FALSE(snap_phantom_window_controller());
660 666
661 // The pointer is on the edge but not shared. The snap phantom window 667 // The pointer is on the edge but not shared. The snap phantom window
662 // controller should be non-NULL. 668 // controller should be non-NULL.
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
1495 1501
1496 std::unique_ptr<WindowResizer> resizer( 1502 std::unique_ptr<WindowResizer> resizer(
1497 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT)); 1503 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT));
1498 resizer->Drag(CalculateDragPoint(*resizer, 2, 2), 0); 1504 resizer->Drag(CalculateDragPoint(*resizer, 2, 2), 0);
1499 EXPECT_EQ(401, window_->bounds().width()); 1505 EXPECT_EQ(401, window_->bounds().width());
1500 EXPECT_EQ(302, window_->bounds().height()); 1506 EXPECT_EQ(302, window_->bounds().height());
1501 } 1507 }
1502 1508
1503 // Test that a window with a specified max size can't be snapped. 1509 // Test that a window with a specified max size can't be snapped.
1504 TEST_P(WorkspaceWindowResizerTest, PhantomSnapMaxSize) { 1510 TEST_P(WorkspaceWindowResizerTest, PhantomSnapMaxSize) {
1511 // Make the window snappable by making it resizable and maximizable.
1512 window_->SetProperty(aura::client::kResizeBehaviorKey,
1513 ui::mojom::kResizeBehaviorCanResize |
1514 ui::mojom::kResizeBehaviorCanMaximize);
1515
1516 // Enable docking for this test.
1517 base::CommandLine::ForCurrentProcess()->AppendSwitch(
1518 ash::switches::kAshEnableDockedWindows);
1519
1505 { 1520 {
1506 // With max size not set we get a phantom window controller for dragging off 1521 // With max size not set we get a phantom window controller for dragging off
1507 // the right hand side. 1522 // the right hand side.
1508 // Make the window wider than maximum docked width. 1523 // Make the window wider than maximum docked width.
1509 window_->SetBounds(gfx::Rect(0, 0, 400, 200)); 1524 window_->SetBounds(gfx::Rect(0, 0, 400, 200));
1510 1525
1511 std::unique_ptr<WindowResizer> resizer( 1526 std::unique_ptr<WindowResizer> resizer(
1512 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); 1527 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
1513 EXPECT_FALSE(snap_phantom_window_controller()); 1528 EXPECT_FALSE(snap_phantom_window_controller());
1514 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0); 1529 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0);
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 touch_resize_window_->bounds().ToString()); 1901 touch_resize_window_->bounds().ToString());
1887 // Drag even more to snap to the edge. 1902 // Drag even more to snap to the edge.
1888 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), 1903 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40),
1889 gfx::Point(400, kRootHeight - 25), 1904 gfx::Point(400, kRootHeight - 25),
1890 base::TimeDelta::FromMilliseconds(10), 5); 1905 base::TimeDelta::FromMilliseconds(10), 5);
1891 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), 1906 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(),
1892 touch_resize_window_->bounds().ToString()); 1907 touch_resize_window_->bounds().ToString());
1893 } 1908 }
1894 1909
1895 } // namespace ash 1910 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698