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/wm/drag_window_resizer.h" | 5 #include "ash/wm/drag_window_resizer.h" |
6 | 6 |
7 #include "ash/display/mouse_cursor_event_filter.h" | 7 #include "ash/display/mouse_cursor_event_filter.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
11 #include "ash/shell_window_ids.h" | 11 #include "ash/shell_window_ids.h" |
12 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
13 #include "ash/test/cursor_manager_test_api.h" | 13 #include "ash/test/cursor_manager_test_api.h" |
14 #include "ash/wm/drag_window_controller.h" | 14 #include "ash/wm/drag_window_controller.h" |
15 #include "ash/wm/window_util.h" | 15 #include "ash/wm/window_util.h" |
| 16 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
17 #include "ui/aura/client/aura_constants.h" | 18 #include "ui/aura/client/aura_constants.h" |
18 #include "ui/aura/root_window.h" | 19 #include "ui/aura/root_window.h" |
19 #include "ui/aura/test/test_window_delegate.h" | 20 #include "ui/aura/test/test_window_delegate.h" |
20 #include "ui/base/hit_test.h" | 21 #include "ui/base/hit_test.h" |
21 #include "ui/base/ui_base_types.h" | 22 #include "ui/base/ui_base_types.h" |
22 #include "ui/gfx/insets.h" | 23 #include "ui/gfx/insets.h" |
23 #include "ui/gfx/screen.h" | 24 #include "ui/gfx/screen.h" |
24 #include "ui/views/widget/widget.h" | 25 #include "ui/views/widget/widget.h" |
25 | 26 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 } | 185 } |
185 | 186 |
186 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), | 187 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), |
187 Shell::GetScreen()->GetPrimaryDisplay()); | 188 Shell::GetScreen()->GetPrimaryDisplay()); |
188 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 189 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
189 { | 190 { |
190 // Grab (0, 0) of the window and move the pointer to (790, 10). | 191 // Grab (0, 0) of the window and move the pointer to (790, 10). |
191 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( | 192 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( |
192 window_.get(), gfx::Point(), HTCAPTION)); | 193 window_.get(), gfx::Point(), HTCAPTION)); |
193 ASSERT_TRUE(resizer.get()); | 194 ASSERT_TRUE(resizer.get()); |
194 resizer->Drag(CalculateDragPoint(*resizer, 790, 10), 0); | 195 resizer->Drag(CalculateDragPoint(*resizer, 795, 10), 0); |
| 196 // Window should be adjusted for minimum visibility (10px) during the drag. |
| 197 EXPECT_EQ("790,10 50x60", window_->bounds().ToString()); |
195 resizer->CompleteDrag(0); | 198 resizer->CompleteDrag(0); |
196 // Since the pointer is still on the primary root window, the parent should | 199 // Since the pointer is still on the primary root window, the parent should |
197 // not be changed. | 200 // not be changed. |
| 201 // Window origin should be adjusted for minimum visibility (10px). |
198 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 202 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
199 EXPECT_EQ("790,10 50x60", window_->bounds().ToString()); | 203 EXPECT_EQ("790,10 50x60", window_->bounds().ToString()); |
200 } | 204 } |
201 | 205 |
202 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), | 206 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), |
203 Shell::GetScreen()->GetPrimaryDisplay()); | 207 Shell::GetScreen()->GetPrimaryDisplay()); |
204 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 208 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
205 { | 209 { |
206 // Grab the top-right edge of the window and move the pointer to (0, 10) | 210 // Grab the top-right edge of the window and move the pointer to (0, 10) |
207 // in the secondary root window's coordinates. | 211 // in the secondary root window's coordinates. |
208 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( | 212 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( |
209 window_.get(), gfx::Point(49, 0), HTCAPTION)); | 213 window_.get(), gfx::Point(49, 0), HTCAPTION)); |
210 ASSERT_TRUE(resizer.get()); | 214 ASSERT_TRUE(resizer.get()); |
211 resizer->Drag(CalculateDragPoint(*resizer, 751, 10), ui::EF_CONTROL_DOWN); | 215 resizer->Drag(CalculateDragPoint(*resizer, 751, 10), ui::EF_CONTROL_DOWN); |
212 resizer->CompleteDrag(0); | 216 resizer->CompleteDrag(0); |
213 // Since the pointer is on the secondary, the parent should be changed | 217 // Since the pointer is on the secondary, the parent should be changed |
214 // even though only small fraction of the window is within the secondary | 218 // even though only small fraction of the window is within the secondary |
215 // root window's bounds. | 219 // root window's bounds. |
216 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | 220 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
217 EXPECT_EQ("-49,10 50x60", window_->bounds().ToString()); | 221 // Window origin should be adjusted for minimum visibility (10px). |
| 222 int expected_x = -50 + 10; |
| 223 EXPECT_EQ(base::IntToString(expected_x) + ",10 50x60", |
| 224 window_->bounds().ToString()); |
218 } | 225 } |
219 } | 226 } |
220 | 227 |
221 // Verifies that dragging the active window to another display makes the new | 228 // Verifies that dragging the active window to another display makes the new |
222 // root window the active root window. | 229 // root window the active root window. |
223 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysActiveRoot) { | 230 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysActiveRoot) { |
224 if (!SupportsMultipleDisplays()) | 231 if (!SupportsMultipleDisplays()) |
225 return; | 232 return; |
226 | 233 |
227 // The secondary display is logically on the right, but on the system (e.g. X) | 234 // The secondary display is logically on the right, but on the system (e.g. X) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | 280 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
274 { | 281 { |
275 // Grab (0, 0) of the window. | 282 // Grab (0, 0) of the window. |
276 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( | 283 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( |
277 window_.get(), gfx::Point(), HTCAPTION)); | 284 window_.get(), gfx::Point(), HTCAPTION)); |
278 ASSERT_TRUE(resizer.get()); | 285 ASSERT_TRUE(resizer.get()); |
279 // Move the mouse near the right edge, (798, 0), of the primary display. | 286 // Move the mouse near the right edge, (798, 0), of the primary display. |
280 resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN); | 287 resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN); |
281 resizer->CompleteDrag(0); | 288 resizer->CompleteDrag(0); |
282 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 289 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
283 EXPECT_EQ("798,0 50x60", window_->bounds().ToString()); | 290 // Window origin should be adjusted for minimum visibility (10px). |
| 291 int expected_x = 800 - 10; |
| 292 EXPECT_EQ(base::IntToString(expected_x) + ",0 50x60", |
| 293 window_->bounds().ToString()); |
284 } | 294 } |
285 } | 295 } |
286 | 296 |
287 // Verifies the drag window is shown correctly. | 297 // Verifies the drag window is shown correctly. |
288 TEST_F(DragWindowResizerTest, DragWindowController) { | 298 TEST_F(DragWindowResizerTest, DragWindowController) { |
289 if (!SupportsMultipleDisplays()) | 299 if (!SupportsMultipleDisplays()) |
290 return; | 300 return; |
291 | 301 |
292 UpdateDisplay("800x600,800x600"); | 302 UpdateDisplay("800x600,800x600"); |
293 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 303 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 resizer->CompleteDrag(0); | 665 resizer->CompleteDrag(0); |
656 EXPECT_EQ(1, session_delegate->num_transfer_to_desktop_of_user_calls()); | 666 EXPECT_EQ(1, session_delegate->num_transfer_to_desktop_of_user_calls()); |
657 EXPECT_NE(initial_bounds.ToString(), window->bounds().ToString()); | 667 EXPECT_NE(initial_bounds.ToString(), window->bounds().ToString()); |
658 } | 668 } |
659 } | 669 } |
660 #endif | 670 #endif |
661 | 671 |
662 | 672 |
663 } // namespace internal | 673 } // namespace internal |
664 } // namespace ash | 674 } // namespace ash |
OLD | NEW |