| 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_resizer.h" | 5 #include "ash/wm/dock/docked_window_resizer.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/screen_util.h" | 9 #include "ash/screen_util.h" |
| 10 #include "ash/shelf/shelf.h" | 10 #include "ash/shelf/shelf.h" |
| 11 #include "ash/shelf/shelf_layout_manager.h" | 11 #include "ash/shelf/shelf_layout_manager.h" |
| 12 #include "ash/shelf/shelf_model.h" | 12 #include "ash/shelf/shelf_model.h" |
| 13 #include "ash/shelf/shelf_types.h" | 13 #include "ash/shelf/shelf_types.h" |
| 14 #include "ash/shelf/shelf_widget.h" | 14 #include "ash/shelf/shelf_widget.h" |
| 15 #include "ash/shell.h" | 15 #include "ash/shell.h" |
| 16 #include "ash/shell_window_ids.h" | 16 #include "ash/shell_window_ids.h" |
| 17 #include "ash/test/ash_test_base.h" | 17 #include "ash/test/ash_test_base.h" |
| 18 #include "ash/test/cursor_manager_test_api.h" | 18 #include "ash/test/cursor_manager_test_api.h" |
| 19 #include "ash/test/shell_test_api.h" | 19 #include "ash/test/shell_test_api.h" |
| 20 #include "ash/test/test_shelf_delegate.h" | 20 #include "ash/test/test_shelf_delegate.h" |
| 21 #include "ash/wm/coordinate_conversion.h" |
| 21 #include "ash/wm/dock/docked_window_layout_manager.h" | 22 #include "ash/wm/dock/docked_window_layout_manager.h" |
| 22 #include "ash/wm/drag_window_resizer.h" | 23 #include "ash/wm/drag_window_resizer.h" |
| 23 #include "ash/wm/panels/panel_layout_manager.h" | 24 #include "ash/wm/panels/panel_layout_manager.h" |
| 24 #include "ash/wm/window_state.h" | 25 #include "ash/wm/window_state.h" |
| 25 #include "ash/wm/window_util.h" | 26 #include "ash/wm/window_util.h" |
| 26 #include "ash/wm/wm_event.h" | 27 #include "ash/wm/wm_event.h" |
| 27 #include "base/command_line.h" | 28 #include "base/command_line.h" |
| 28 #include "ui/aura/client/aura_constants.h" | 29 #include "ui/aura/client/aura_constants.h" |
| 29 #include "ui/aura/client/window_tree_client.h" | 30 #include "ui/aura/client/window_tree_client.h" |
| 30 #include "ui/aura/test/test_window_delegate.h" | 31 #include "ui/aura/test/test_window_delegate.h" |
| 31 #include "ui/aura/window_event_dispatcher.h" | 32 #include "ui/aura/window_event_dispatcher.h" |
| 32 #include "ui/base/hit_test.h" | 33 #include "ui/base/hit_test.h" |
| 33 #include "ui/base/ui_base_types.h" | 34 #include "ui/base/ui_base_types.h" |
| 34 #include "ui/events/test/event_generator.h" | 35 #include "ui/events/test/event_generator.h" |
| 35 #include "ui/views/widget/widget.h" | 36 #include "ui/views/widget/widget.h" |
| 36 #include "ui/wm/core/coordinate_conversion.h" | |
| 37 #include "ui/wm/core/window_util.h" | 37 #include "ui/wm/core/window_util.h" |
| 38 | 38 |
| 39 namespace ash { | 39 namespace ash { |
| 40 | 40 |
| 41 class DockedWindowResizerTest | 41 class DockedWindowResizerTest |
| 42 : public test::AshTestBase, | 42 : public test::AshTestBase, |
| 43 public testing::WithParamInterface<ui::wm::WindowType> { | 43 public testing::WithParamInterface<ui::wm::WindowType> { |
| 44 public: | 44 public: |
| 45 DockedWindowResizerTest() : model_(NULL), window_type_(GetParam()) {} | 45 DockedWindowResizerTest() : model_(NULL), window_type_(GetParam()) {} |
| 46 virtual ~DockedWindowResizerTest() {} | 46 virtual ~DockedWindowResizerTest() {} |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 window->Show(); | 98 window->Show(); |
| 99 | 99 |
| 100 if (bounds.IsEmpty()) { | 100 if (bounds.IsEmpty()) { |
| 101 ParentWindowInPrimaryRootWindow(window); | 101 ParentWindowInPrimaryRootWindow(window); |
| 102 } else { | 102 } else { |
| 103 gfx::Display display = | 103 gfx::Display display = |
| 104 Shell::GetScreen()->GetDisplayMatching(bounds); | 104 Shell::GetScreen()->GetDisplayMatching(bounds); |
| 105 aura::Window* root = ash::Shell::GetInstance()->display_controller()-> | 105 aura::Window* root = ash::Shell::GetInstance()->display_controller()-> |
| 106 GetRootWindowForDisplayId(display.id()); | 106 GetRootWindowForDisplayId(display.id()); |
| 107 gfx::Point origin = bounds.origin(); | 107 gfx::Point origin = bounds.origin(); |
| 108 ::wm::ConvertPointFromScreen(root, &origin); | 108 wm::ConvertPointFromScreen(root, &origin); |
| 109 window->SetBounds(gfx::Rect(origin, bounds.size())); | 109 window->SetBounds(gfx::Rect(origin, bounds.size())); |
| 110 aura::client::ParentWindowWithContext(window, root, bounds); | 110 aura::client::ParentWindowWithContext(window, root, bounds); |
| 111 } | 111 } |
| 112 return window; | 112 return window; |
| 113 } | 113 } |
| 114 | 114 |
| 115 static WindowResizer* CreateSomeWindowResizer( | 115 static WindowResizer* CreateSomeWindowResizer( |
| 116 aura::Window* window, | 116 aura::Window* window, |
| 117 const gfx::Point& point_in_parent, | 117 const gfx::Point& point_in_parent, |
| 118 int window_component) { | 118 int window_component) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 int dx, int dy, | 209 int dx, int dy, |
| 210 int grab_x, int grab_y) { | 210 int grab_x, int grab_y) { |
| 211 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 211 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
| 212 // avoid snap by clicking away from the border | 212 // avoid snap by clicking away from the border |
| 213 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(window, | 213 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(window, |
| 214 grab_x, grab_y)); | 214 grab_x, grab_y)); |
| 215 | 215 |
| 216 gfx::Rect work_area = | 216 gfx::Rect work_area = |
| 217 Shell::GetScreen()->GetDisplayNearestWindow(window).work_area(); | 217 Shell::GetScreen()->GetDisplayNearestWindow(window).work_area(); |
| 218 gfx::Point initial_location_in_screen = initial_location_in_parent_; | 218 gfx::Point initial_location_in_screen = initial_location_in_parent_; |
| 219 ::wm::ConvertPointToScreen(window->parent(), &initial_location_in_screen); | 219 wm::ConvertPointToScreen(window->parent(), &initial_location_in_screen); |
| 220 // Drag the window left or right to the edge (or almost to it). | 220 // Drag the window left or right to the edge (or almost to it). |
| 221 if (edge == DOCKED_EDGE_LEFT) | 221 if (edge == DOCKED_EDGE_LEFT) |
| 222 dx += work_area.x() - initial_location_in_screen.x(); | 222 dx += work_area.x() - initial_location_in_screen.x(); |
| 223 else if (edge == DOCKED_EDGE_RIGHT) | 223 else if (edge == DOCKED_EDGE_RIGHT) |
| 224 dx += work_area.right() - 1 - initial_location_in_screen.x(); | 224 dx += work_area.right() - 1 - initial_location_in_screen.x(); |
| 225 DragMove(dx, dy); | 225 DragMove(dx, dy); |
| 226 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); | 226 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); |
| 227 // Release the mouse and the panel should be attached to the dock. | 227 // Release the mouse and the panel should be attached to the dock. |
| 228 DragEnd(); | 228 DragEnd(); |
| 229 | 229 |
| (...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 EXPECT_TRUE(window_state->IsMaximized()); | 1604 EXPECT_TRUE(window_state->IsMaximized()); |
| 1605 } | 1605 } |
| 1606 | 1606 |
| 1607 // Tests run twice - on both panels and normal windows | 1607 // Tests run twice - on both panels and normal windows |
| 1608 INSTANTIATE_TEST_CASE_P(NormalOrPanel, | 1608 INSTANTIATE_TEST_CASE_P(NormalOrPanel, |
| 1609 DockedWindowResizerTest, | 1609 DockedWindowResizerTest, |
| 1610 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, | 1610 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, |
| 1611 ui::wm::WINDOW_TYPE_PANEL)); | 1611 ui::wm::WINDOW_TYPE_PANEL)); |
| 1612 | 1612 |
| 1613 } // namespace ash | 1613 } // namespace ash |
| OLD | NEW |