OLD | NEW |
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/common/shell_window_ids.h" | 8 #include "ash/common/shell_window_ids.h" |
8 #include "ash/common/wm/window_positioning_utils.h" | 9 #include "ash/common/wm/window_positioning_utils.h" |
9 #include "ash/common/wm/window_state.h" | 10 #include "ash/common/wm/window_state.h" |
10 #include "ash/common/wm/wm_event.h" | 11 #include "ash/common/wm/wm_event.h" |
11 #include "ash/common/wm/workspace/phantom_window_controller.h" | 12 #include "ash/common/wm/workspace/phantom_window_controller.h" |
12 #include "ash/display/display_manager.h" | 13 #include "ash/display/display_manager.h" |
13 #include "ash/screen_util.h" | 14 #include "ash/screen_util.h" |
14 #include "ash/shelf/shelf.h" | 15 #include "ash/shelf/shelf.h" |
15 #include "ash/shell.h" | 16 #include "ash/shell.h" |
16 #include "ash/test/ash_test_base.h" | 17 #include "ash/test/ash_test_base.h" |
17 #include "ash/test/display_manager_test_api.h" | 18 #include "ash/test/display_manager_test_api.h" |
18 #include "ash/wm/aura/wm_window_aura.h" | |
19 #include "ash/wm/window_state_aura.h" | 19 #include "ash/wm/window_state_aura.h" |
20 #include "ash/wm/window_util.h" | 20 #include "ash/wm/window_util.h" |
21 #include "ash/wm/workspace_controller.h" | 21 #include "ash/wm/workspace_controller.h" |
22 #include "base/command_line.h" | 22 #include "base/command_line.h" |
23 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
24 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
25 #include "ui/aura/client/aura_constants.h" | 25 #include "ui/aura/client/aura_constants.h" |
26 #include "ui/aura/test/test_window_delegate.h" | 26 #include "ui/aura/test/test_window_delegate.h" |
27 #include "ui/aura/window_event_dispatcher.h" | 27 #include "ui/aura/window_event_dispatcher.h" |
28 #include "ui/base/hit_test.h" | 28 #include "ui/base/hit_test.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 } | 142 } |
143 return result; | 143 return result; |
144 } | 144 } |
145 | 145 |
146 protected: | 146 protected: |
147 WindowResizer* CreateResizerForTest( | 147 WindowResizer* CreateResizerForTest( |
148 aura::Window* window, | 148 aura::Window* window, |
149 const gfx::Point& point_in_parent, | 149 const gfx::Point& point_in_parent, |
150 int window_component) { | 150 int window_component) { |
151 WindowResizer* resizer = | 151 WindowResizer* resizer = |
152 CreateWindowResizer(wm::WmWindowAura::Get(window), point_in_parent, | 152 CreateWindowResizer(WmWindowAura::Get(window), point_in_parent, |
153 window_component, | 153 window_component, |
154 aura::client::WINDOW_MOVE_SOURCE_MOUSE) | 154 aura::client::WINDOW_MOVE_SOURCE_MOUSE) |
155 .release(); | 155 .release(); |
156 workspace_resizer_ = WorkspaceWindowResizer::GetInstanceForTest(); | 156 workspace_resizer_ = WorkspaceWindowResizer::GetInstanceForTest(); |
157 return resizer; | 157 return resizer; |
158 } | 158 } |
159 WorkspaceWindowResizer* CreateWorkspaceResizerForTest( | 159 WorkspaceWindowResizer* CreateWorkspaceResizerForTest( |
160 aura::Window* window, | 160 aura::Window* window, |
161 const gfx::Point& point_in_parent, | 161 const gfx::Point& point_in_parent, |
162 int window_component, | 162 int window_component, |
163 aura::client::WindowMoveSource source, | 163 aura::client::WindowMoveSource source, |
164 const std::vector<aura::Window*>& attached_windows) { | 164 const std::vector<aura::Window*>& attached_windows) { |
165 wm::WindowState* window_state = wm::GetWindowState(window); | 165 wm::WindowState* window_state = wm::GetWindowState(window); |
166 window_state->CreateDragDetails(point_in_parent, window_component, source); | 166 window_state->CreateDragDetails(point_in_parent, window_component, source); |
167 return WorkspaceWindowResizer::Create( | 167 return WorkspaceWindowResizer::Create( |
168 window_state, wm::WmWindowAura::FromAuraWindows(attached_windows)); | 168 window_state, WmWindowAura::FromAuraWindows(attached_windows)); |
169 } | 169 } |
170 | 170 |
171 PhantomWindowController* snap_phantom_window_controller() const { | 171 PhantomWindowController* snap_phantom_window_controller() const { |
172 return workspace_resizer_->snap_phantom_window_controller_.get(); | 172 return workspace_resizer_->snap_phantom_window_controller_.get(); |
173 } | 173 } |
174 | 174 |
175 gfx::Point CalculateDragPoint(const WindowResizer& resizer, | 175 gfx::Point CalculateDragPoint(const WindowResizer& resizer, |
176 int delta_x, | 176 int delta_x, |
177 int delta_y) const { | 177 int delta_y) const { |
178 gfx::Point location = resizer.GetInitialLocation(); | 178 gfx::Point location = resizer.GetInitialLocation(); |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 // TODO(varkha): Insets are reset after every drag because of | 561 // TODO(varkha): Insets are reset after every drag because of |
562 // http://crbug.com/292238. | 562 // http://crbug.com/292238. |
563 // Window is wide enough not to get docked right away. | 563 // Window is wide enough not to get docked right away. |
564 window_->SetBounds(gfx::Rect(20, 30, 400, 60)); | 564 window_->SetBounds(gfx::Rect(20, 30, 400, 60)); |
565 window_->SetProperty(aura::client::kCanMaximizeKey, true); | 565 window_->SetProperty(aura::client::kCanMaximizeKey, true); |
566 wm::WindowState* window_state = wm::GetWindowState(window_.get()); | 566 wm::WindowState* window_state = wm::GetWindowState(window_.get()); |
567 | 567 |
568 { | 568 { |
569 gfx::Rect expected_bounds_in_parent( | 569 gfx::Rect expected_bounds_in_parent( |
570 wm::GetDefaultLeftSnappedWindowBoundsInParent( | 570 wm::GetDefaultLeftSnappedWindowBoundsInParent( |
571 wm::WmWindowAura::Get(window_.get()))); | 571 WmWindowAura::Get(window_.get()))); |
572 | 572 |
573 std::unique_ptr<WindowResizer> resizer( | 573 std::unique_ptr<WindowResizer> resizer( |
574 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); | 574 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); |
575 ASSERT_TRUE(resizer.get()); | 575 ASSERT_TRUE(resizer.get()); |
576 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0); | 576 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0); |
577 resizer->CompleteDrag(); | 577 resizer->CompleteDrag(); |
578 | 578 |
579 EXPECT_EQ(expected_bounds_in_parent.ToString(), | 579 EXPECT_EQ(expected_bounds_in_parent.ToString(), |
580 window_->bounds().ToString()); | 580 window_->bounds().ToString()); |
581 ASSERT_TRUE(window_state->HasRestoreBounds()); | 581 ASSERT_TRUE(window_state->HasRestoreBounds()); |
582 EXPECT_EQ("20,30 400x60", | 582 EXPECT_EQ("20,30 400x60", |
583 window_state->GetRestoreBoundsInScreen().ToString()); | 583 window_state->GetRestoreBoundsInScreen().ToString()); |
584 } | 584 } |
585 // Try the same with the right side. | 585 // Try the same with the right side. |
586 { | 586 { |
587 gfx::Rect expected_bounds_in_parent( | 587 gfx::Rect expected_bounds_in_parent( |
588 wm::GetDefaultRightSnappedWindowBoundsInParent( | 588 wm::GetDefaultRightSnappedWindowBoundsInParent( |
589 wm::WmWindowAura::Get(window_.get()))); | 589 WmWindowAura::Get(window_.get()))); |
590 | 590 |
591 std::unique_ptr<WindowResizer> resizer( | 591 std::unique_ptr<WindowResizer> resizer( |
592 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); | 592 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); |
593 ASSERT_TRUE(resizer.get()); | 593 ASSERT_TRUE(resizer.get()); |
594 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); | 594 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); |
595 resizer->CompleteDrag(); | 595 resizer->CompleteDrag(); |
596 EXPECT_EQ(expected_bounds_in_parent.ToString(), | 596 EXPECT_EQ(expected_bounds_in_parent.ToString(), |
597 window_->bounds().ToString()); | 597 window_->bounds().ToString()); |
598 ASSERT_TRUE(window_state->HasRestoreBounds()); | 598 ASSERT_TRUE(window_state->HasRestoreBounds()); |
599 EXPECT_EQ("20,30 400x60", | 599 EXPECT_EQ("20,30 400x60", |
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1886 // Drag even more to snap to the edge. | 1886 // Drag even more to snap to the edge. |
1887 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), | 1887 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), |
1888 gfx::Point(400, kRootHeight - 25), | 1888 gfx::Point(400, kRootHeight - 25), |
1889 base::TimeDelta::FromMilliseconds(10), | 1889 base::TimeDelta::FromMilliseconds(10), |
1890 5); | 1890 5); |
1891 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), | 1891 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), |
1892 touch_resize_window_->bounds().ToString()); | 1892 touch_resize_window_->bounds().ToString()); |
1893 } | 1893 } |
1894 | 1894 |
1895 } // namespace ash | 1895 } // namespace ash |
OLD | NEW |