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/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
| 8 #include "ash/common/material_design/material_design_controller.h" |
8 #include "ash/common/shell_window_ids.h" | 9 #include "ash/common/shell_window_ids.h" |
9 #include "ash/common/wm/window_positioning_utils.h" | 10 #include "ash/common/wm/window_positioning_utils.h" |
10 #include "ash/display/display_manager.h" | 11 #include "ash/display/display_manager.h" |
11 #include "ash/display/mouse_cursor_event_filter.h" | 12 #include "ash/display/mouse_cursor_event_filter.h" |
12 #include "ash/root_window_controller.h" | 13 #include "ash/root_window_controller.h" |
13 #include "ash/shelf/shelf_layout_manager.h" | 14 #include "ash/shelf/shelf_layout_manager.h" |
14 #include "ash/shell.h" | 15 #include "ash/shell.h" |
15 #include "ash/test/ash_test_base.h" | 16 #include "ash/test/ash_md_test_base.h" |
16 #include "ash/test/cursor_manager_test_api.h" | 17 #include "ash/test/cursor_manager_test_api.h" |
17 #include "ash/test/display_manager_test_api.h" | 18 #include "ash/test/display_manager_test_api.h" |
18 #include "ash/wm/drag_window_controller.h" | 19 #include "ash/wm/drag_window_controller.h" |
19 #include "ash/wm/window_util.h" | 20 #include "ash/wm/window_util.h" |
20 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
21 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
22 #include "ui/aura/client/aura_constants.h" | 23 #include "ui/aura/client/aura_constants.h" |
23 #include "ui/aura/env.h" | 24 #include "ui/aura/env.h" |
24 #include "ui/aura/test/test_window_delegate.h" | 25 #include "ui/aura/test/test_window_delegate.h" |
25 #include "ui/base/hit_test.h" | 26 #include "ui/base/hit_test.h" |
(...skipping 30 matching lines...) Expand all Loading... |
56 return base::Closure(); | 57 return base::Closure(); |
57 } | 58 } |
58 | 59 |
59 int paint_count_ = 0; | 60 int paint_count_ = 0; |
60 | 61 |
61 DISALLOW_COPY_AND_ASSIGN(TestLayerDelegate); | 62 DISALLOW_COPY_AND_ASSIGN(TestLayerDelegate); |
62 }; | 63 }; |
63 | 64 |
64 } // namespace | 65 } // namespace |
65 | 66 |
66 class DragWindowResizerTest : public test::AshTestBase { | 67 class DragWindowResizerTest : public test::AshMDTestBase { |
67 public: | 68 public: |
68 DragWindowResizerTest() : transient_child_(nullptr) {} | 69 DragWindowResizerTest() : transient_child_(nullptr) {} |
69 ~DragWindowResizerTest() override {} | 70 ~DragWindowResizerTest() override {} |
70 | 71 |
71 void SetUp() override { | 72 void SetUp() override { |
72 AshTestBase::SetUp(); | 73 AshMDTestBase::SetUp(); |
| 74 |
73 UpdateDisplay(base::StringPrintf("800x%d", kRootHeight)); | 75 UpdateDisplay(base::StringPrintf("800x%d", kRootHeight)); |
74 | 76 |
75 aura::Window* root = Shell::GetPrimaryRootWindow(); | 77 aura::Window* root = Shell::GetPrimaryRootWindow(); |
76 gfx::Rect root_bounds(root->bounds()); | 78 gfx::Rect root_bounds(root->bounds()); |
77 EXPECT_EQ(kRootHeight, root_bounds.height()); | 79 EXPECT_EQ(kRootHeight, root_bounds.height()); |
78 EXPECT_EQ(800, root_bounds.width()); | 80 EXPECT_EQ(800, root_bounds.width()); |
79 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 81 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
80 window_.reset(new aura::Window(&delegate_)); | 82 window_.reset(new aura::Window(&delegate_)); |
81 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 83 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
82 window_->Init(ui::LAYER_NOT_DRAWN); | 84 window_->Init(ui::LAYER_NOT_DRAWN); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 panel_window_->Init(ui::LAYER_NOT_DRAWN); | 118 panel_window_->Init(ui::LAYER_NOT_DRAWN); |
117 ParentWindowInPrimaryRootWindow(panel_window_.get()); | 119 ParentWindowInPrimaryRootWindow(panel_window_.get()); |
118 } | 120 } |
119 | 121 |
120 void TearDown() override { | 122 void TearDown() override { |
121 window_.reset(); | 123 window_.reset(); |
122 always_on_top_window_.reset(); | 124 always_on_top_window_.reset(); |
123 system_modal_window_.reset(); | 125 system_modal_window_.reset(); |
124 transient_parent_.reset(); | 126 transient_parent_.reset(); |
125 panel_window_.reset(); | 127 panel_window_.reset(); |
126 AshTestBase::TearDown(); | 128 AshMDTestBase::TearDown(); |
127 } | 129 } |
128 | 130 |
129 protected: | 131 protected: |
130 gfx::Point CalculateDragPoint(const WindowResizer& resizer, | 132 gfx::Point CalculateDragPoint(const WindowResizer& resizer, |
131 int delta_x, | 133 int delta_x, |
132 int delta_y) const { | 134 int delta_y) const { |
133 gfx::Point location = resizer.GetInitialLocation(); | 135 gfx::Point location = resizer.GetInitialLocation(); |
134 location.set_x(location.x() + delta_x); | 136 location.set_x(location.x() + delta_x); |
135 location.set_y(location.y() + delta_y); | 137 location.set_y(location.y() + delta_y); |
136 return location; | 138 return location; |
(...skipping 29 matching lines...) Expand all Loading... |
166 std::unique_ptr<aura::Window> always_on_top_window_; | 168 std::unique_ptr<aura::Window> always_on_top_window_; |
167 std::unique_ptr<aura::Window> system_modal_window_; | 169 std::unique_ptr<aura::Window> system_modal_window_; |
168 std::unique_ptr<aura::Window> panel_window_; | 170 std::unique_ptr<aura::Window> panel_window_; |
169 aura::Window* transient_child_; | 171 aura::Window* transient_child_; |
170 std::unique_ptr<aura::Window> transient_parent_; | 172 std::unique_ptr<aura::Window> transient_parent_; |
171 | 173 |
172 private: | 174 private: |
173 DISALLOW_COPY_AND_ASSIGN(DragWindowResizerTest); | 175 DISALLOW_COPY_AND_ASSIGN(DragWindowResizerTest); |
174 }; | 176 }; |
175 | 177 |
| 178 // The prefix has intentionally been left blank since there is only one |
| 179 // parameterization of this test fixture. |
| 180 INSTANTIATE_TEST_CASE_P( |
| 181 /* prefix intentionally left blank */, |
| 182 DragWindowResizerTest, |
| 183 testing::Values(MaterialDesignController::NON_MATERIAL, |
| 184 MaterialDesignController::MATERIAL_NORMAL, |
| 185 MaterialDesignController::MATERIAL_EXPERIMENTAL)); |
| 186 |
176 // Verifies a window can be moved from the primary display to another. | 187 // Verifies a window can be moved from the primary display to another. |
177 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplays) { | 188 TEST_P(DragWindowResizerTest, WindowDragWithMultiDisplays) { |
178 if (!SupportsMultipleDisplays()) | 189 if (!SupportsMultipleDisplays()) |
179 return; | 190 return; |
| 191 const int height_offset = GetMdMaximizedWindowHeightOffset(); |
180 | 192 |
181 // The secondary display is logically on the right, but on the system (e.g. X) | 193 // The secondary display is logically on the right, but on the system (e.g. X) |
182 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. | 194 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. |
183 UpdateDisplay("800x600,400x300"); | 195 UpdateDisplay("800x600,400x300"); |
184 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 196 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
185 ASSERT_EQ(2U, root_windows.size()); | 197 ASSERT_EQ(2U, root_windows.size()); |
186 | 198 |
187 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), | 199 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), |
188 display::Screen::GetScreen()->GetPrimaryDisplay()); | 200 display::Screen::GetScreen()->GetPrimaryDisplay()); |
189 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 201 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 { | 262 { |
251 // Grab the top-right edge of the window and move the pointer to (0, 10) | 263 // Grab the top-right edge of the window and move the pointer to (0, 10) |
252 // in the secondary root window's coordinates. | 264 // in the secondary root window's coordinates. |
253 std::unique_ptr<WindowResizer> resizer( | 265 std::unique_ptr<WindowResizer> resizer( |
254 CreateDragWindowResizer(window_.get(), gfx::Point(699, 0), HTCAPTION)); | 266 CreateDragWindowResizer(window_.get(), gfx::Point(699, 0), HTCAPTION)); |
255 ASSERT_TRUE(resizer.get()); | 267 ASSERT_TRUE(resizer.get()); |
256 resizer->Drag(CalculateDragPoint(*resizer, 101, 10), ui::EF_CONTROL_DOWN); | 268 resizer->Drag(CalculateDragPoint(*resizer, 101, 10), ui::EF_CONTROL_DOWN); |
257 resizer->CompleteDrag(); | 269 resizer->CompleteDrag(); |
258 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | 270 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
259 // Window size should be adjusted to fit to the work area | 271 // Window size should be adjusted to fit to the work area |
260 EXPECT_EQ("400x253", window_->bounds().size().ToString()); | 272 EXPECT_EQ(gfx::Size(400, 253 + height_offset).ToString(), |
| 273 window_->bounds().size().ToString()); |
261 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen(); | 274 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen(); |
262 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen()); | 275 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen()); |
263 intersect.Intersect(window_bounds_in_screen); | 276 intersect.Intersect(window_bounds_in_screen); |
264 | 277 |
265 EXPECT_LE(10, intersect.width()); | 278 EXPECT_LE(10, intersect.width()); |
266 EXPECT_LE(10, intersect.height()); | 279 EXPECT_LE(10, intersect.height()); |
267 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(800, 10))); | 280 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(800, 10))); |
268 } | 281 } |
269 | 282 |
270 // Dropping a window that is larger than the destination work area | 283 // Dropping a window that is larger than the destination work area |
271 // will shrink to fit to the work area. | 284 // will shrink to fit to the work area. |
272 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500), | 285 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500), |
273 display::Screen::GetScreen()->GetPrimaryDisplay()); | 286 display::Screen::GetScreen()->GetPrimaryDisplay()); |
274 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 287 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
275 { | 288 { |
276 // Grab the top-left edge of the window and move the pointer to (150, 10) | 289 // Grab the top-left edge of the window and move the pointer to (150, 10) |
277 // in the secondary root window's coordinates. Make sure the window is | 290 // in the secondary root window's coordinates. Make sure the window is |
278 // shrink in such a way that it keeps the cursor within. | 291 // shrink in such a way that it keeps the cursor within. |
279 std::unique_ptr<WindowResizer> resizer( | 292 std::unique_ptr<WindowResizer> resizer( |
280 CreateDragWindowResizer(window_.get(), gfx::Point(0, 0), HTCAPTION)); | 293 CreateDragWindowResizer(window_.get(), gfx::Point(0, 0), HTCAPTION)); |
281 ASSERT_TRUE(resizer.get()); | 294 ASSERT_TRUE(resizer.get()); |
282 resizer->Drag(CalculateDragPoint(*resizer, 799, 10), ui::EF_CONTROL_DOWN); | 295 resizer->Drag(CalculateDragPoint(*resizer, 799, 10), ui::EF_CONTROL_DOWN); |
283 resizer->Drag(CalculateDragPoint(*resizer, 850, 10), ui::EF_CONTROL_DOWN); | 296 resizer->Drag(CalculateDragPoint(*resizer, 850, 10), ui::EF_CONTROL_DOWN); |
284 resizer->CompleteDrag(); | 297 resizer->CompleteDrag(); |
285 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | 298 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
286 // Window size should be adjusted to fit to the work area | 299 // Window size should be adjusted to fit to the work area |
287 EXPECT_EQ("400x253", window_->bounds().size().ToString()); | 300 EXPECT_EQ(gfx::Size(400, 253 + height_offset).ToString(), |
| 301 window_->bounds().size().ToString()); |
288 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen(); | 302 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen(); |
289 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen()); | 303 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen()); |
290 intersect.Intersect(window_bounds_in_screen); | 304 intersect.Intersect(window_bounds_in_screen); |
291 EXPECT_LE(10, intersect.width()); | 305 EXPECT_LE(10, intersect.width()); |
292 EXPECT_LE(10, intersect.height()); | 306 EXPECT_LE(10, intersect.height()); |
293 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(850, 10))); | 307 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(850, 10))); |
294 } | 308 } |
295 } | 309 } |
296 | 310 |
297 // Verifies that dragging the active window to another display makes the new | 311 // Verifies that dragging the active window to another display makes the new |
298 // root window the active root window. | 312 // root window the active root window. |
299 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysActiveRoot) { | 313 TEST_P(DragWindowResizerTest, WindowDragWithMultiDisplaysActiveRoot) { |
300 if (!SupportsMultipleDisplays()) | 314 if (!SupportsMultipleDisplays()) |
301 return; | 315 return; |
302 | 316 |
303 // The secondary display is logically on the right, but on the system (e.g. X) | 317 // The secondary display is logically on the right, but on the system (e.g. X) |
304 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. | 318 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. |
305 UpdateDisplay("800x600,800x600"); | 319 UpdateDisplay("800x600,800x600"); |
306 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 320 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
307 ASSERT_EQ(2U, root_windows.size()); | 321 ASSERT_EQ(2U, root_windows.size()); |
308 | 322 |
309 aura::test::TestWindowDelegate delegate; | 323 aura::test::TestWindowDelegate delegate; |
(...skipping 18 matching lines...) Expand all Loading... |
328 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); | 342 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); |
329 resizer->CompleteDrag(); | 343 resizer->CompleteDrag(); |
330 // The whole window is on the secondary display now. The parent should be | 344 // The whole window is on the secondary display now. The parent should be |
331 // changed. | 345 // changed. |
332 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 346 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
333 EXPECT_EQ(root_windows[1], ash::Shell::GetTargetRootWindow()); | 347 EXPECT_EQ(root_windows[1], ash::Shell::GetTargetRootWindow()); |
334 } | 348 } |
335 } | 349 } |
336 | 350 |
337 // Verifies a window can be moved from the secondary display to primary. | 351 // Verifies a window can be moved from the secondary display to primary. |
338 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysRightToLeft) { | 352 TEST_P(DragWindowResizerTest, WindowDragWithMultiDisplaysRightToLeft) { |
339 if (!SupportsMultipleDisplays()) | 353 if (!SupportsMultipleDisplays()) |
340 return; | 354 return; |
341 | 355 |
342 UpdateDisplay("800x600,800x600"); | 356 UpdateDisplay("800x600,800x600"); |
343 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 357 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
344 ASSERT_EQ(2U, root_windows.size()); | 358 ASSERT_EQ(2U, root_windows.size()); |
345 | 359 |
346 window_->SetBoundsInScreen( | 360 window_->SetBoundsInScreen( |
347 gfx::Rect(800, 00, 50, 60), | 361 gfx::Rect(800, 00, 50, 60), |
348 display::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1])); | 362 display::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1])); |
349 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | 363 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
350 { | 364 { |
351 // Grab (0, 0) of the window. | 365 // Grab (0, 0) of the window. |
352 std::unique_ptr<WindowResizer> resizer( | 366 std::unique_ptr<WindowResizer> resizer( |
353 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION)); | 367 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION)); |
354 ASSERT_TRUE(resizer.get()); | 368 ASSERT_TRUE(resizer.get()); |
355 // Move the mouse near the right edge, (798, 0), of the primary display. | 369 // Move the mouse near the right edge, (798, 0), of the primary display. |
356 resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN); | 370 resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN); |
357 resizer->CompleteDrag(); | 371 resizer->CompleteDrag(); |
358 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 372 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
359 // Window origin should be adjusted for minimum visibility (25px). | 373 // Window origin should be adjusted for minimum visibility (25px). |
360 EXPECT_EQ("775,0 50x60", window_->bounds().ToString()); | 374 EXPECT_EQ("775,0 50x60", window_->bounds().ToString()); |
361 } | 375 } |
362 } | 376 } |
363 | 377 |
364 // Verifies the drag window is shown correctly. | 378 // Verifies the drag window is shown correctly. |
365 TEST_F(DragWindowResizerTest, DragWindowController) { | 379 TEST_P(DragWindowResizerTest, DragWindowController) { |
366 if (!SupportsMultipleDisplays()) | 380 if (!SupportsMultipleDisplays()) |
367 return; | 381 return; |
368 | 382 |
369 UpdateDisplay("800x600,800x600"); | 383 UpdateDisplay("800x600,800x600"); |
370 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 384 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
371 ASSERT_EQ(2U, root_windows.size()); | 385 ASSERT_EQ(2U, root_windows.size()); |
372 | 386 |
373 TestLayerDelegate delegate; | 387 TestLayerDelegate delegate; |
374 window_->layer()->set_delegate(&delegate); | 388 window_->layer()->set_delegate(&delegate); |
375 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), | 389 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 ASSERT_TRUE(drag_resizer); | 462 ASSERT_TRUE(drag_resizer); |
449 EXPECT_FALSE(controller); | 463 EXPECT_FALSE(controller); |
450 | 464 |
451 resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0); | 465 resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0); |
452 resizer->RevertDrag(); | 466 resizer->RevertDrag(); |
453 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 467 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
454 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); | 468 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); |
455 } | 469 } |
456 } | 470 } |
457 | 471 |
458 TEST_F(DragWindowResizerTest, DragWindowControllerAcrossThreeDisplays) { | 472 TEST_P(DragWindowResizerTest, DragWindowControllerAcrossThreeDisplays) { |
459 if (!SupportsMultipleDisplays()) | 473 if (!SupportsMultipleDisplays()) |
460 return; | 474 return; |
461 | 475 |
462 UpdateDisplay("400x600,400x600,800x600"); | 476 UpdateDisplay("400x600,400x600,800x600"); |
463 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 477 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
464 | 478 |
465 // Layout so that all three displays touch each other. | 479 // Layout so that all three displays touch each other. |
466 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 480 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
467 display::DisplayIdList list = display_manager->GetCurrentDisplayIdList(); | 481 display::DisplayIdList list = display_manager->GetCurrentDisplayIdList(); |
468 ASSERT_EQ(3u, list.size()); | 482 ASSERT_EQ(3u, list.size()); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 EXPECT_FLOAT_EQ(0.0f, window_->layer()->opacity()); | 566 EXPECT_FLOAT_EQ(0.0f, window_->layer()->opacity()); |
553 EXPECT_FLOAT_EQ(1.0f, drag_layer0->opacity()); | 567 EXPECT_FLOAT_EQ(1.0f, drag_layer0->opacity()); |
554 | 568 |
555 resizer->CompleteDrag(); | 569 resizer->CompleteDrag(); |
556 EXPECT_EQ(root_windows[2], window_->GetRootWindow()); | 570 EXPECT_EQ(root_windows[2], window_->GetRootWindow()); |
557 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); | 571 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); |
558 } | 572 } |
559 | 573 |
560 // Verifies if the resizer sets and resets | 574 // Verifies if the resizer sets and resets |
561 // MouseCursorEventFilter::mouse_warp_mode_ as expected. | 575 // MouseCursorEventFilter::mouse_warp_mode_ as expected. |
562 TEST_F(DragWindowResizerTest, WarpMousePointer) { | 576 TEST_P(DragWindowResizerTest, WarpMousePointer) { |
563 MouseCursorEventFilter* event_filter = | 577 MouseCursorEventFilter* event_filter = |
564 Shell::GetInstance()->mouse_cursor_filter(); | 578 Shell::GetInstance()->mouse_cursor_filter(); |
565 ASSERT_TRUE(event_filter); | 579 ASSERT_TRUE(event_filter); |
566 window_->SetBounds(gfx::Rect(0, 0, 50, 60)); | 580 window_->SetBounds(gfx::Rect(0, 0, 50, 60)); |
567 | 581 |
568 EXPECT_TRUE(event_filter->mouse_warp_enabled_); | 582 EXPECT_TRUE(event_filter->mouse_warp_enabled_); |
569 { | 583 { |
570 std::unique_ptr<WindowResizer> resizer( | 584 std::unique_ptr<WindowResizer> resizer( |
571 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION)); | 585 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION)); |
572 // While dragging a window, warp should be allowed. | 586 // While dragging a window, warp should be allowed. |
(...skipping 23 matching lines...) Expand all Loading... |
596 std::unique_ptr<WindowResizer> resizer( | 610 std::unique_ptr<WindowResizer> resizer( |
597 CreateDragWindowResizer(window_.get(), gfx::Point(), HTRIGHT)); | 611 CreateDragWindowResizer(window_.get(), gfx::Point(), HTRIGHT)); |
598 EXPECT_FALSE(event_filter->mouse_warp_enabled_); | 612 EXPECT_FALSE(event_filter->mouse_warp_enabled_); |
599 resizer->RevertDrag(); | 613 resizer->RevertDrag(); |
600 } | 614 } |
601 EXPECT_TRUE(event_filter->mouse_warp_enabled_); | 615 EXPECT_TRUE(event_filter->mouse_warp_enabled_); |
602 } | 616 } |
603 | 617 |
604 // Verifies cursor's device scale factor is updated whe a window is moved across | 618 // Verifies cursor's device scale factor is updated whe a window is moved across |
605 // root windows with different device scale factors (http://crbug.com/154183). | 619 // root windows with different device scale factors (http://crbug.com/154183). |
606 TEST_F(DragWindowResizerTest, CursorDeviceScaleFactor) { | 620 TEST_P(DragWindowResizerTest, CursorDeviceScaleFactor) { |
607 if (!SupportsMultipleDisplays()) | 621 if (!SupportsMultipleDisplays()) |
608 return; | 622 return; |
609 | 623 |
610 // The secondary display is logically on the right, but on the system (e.g. X) | 624 // The secondary display is logically on the right, but on the system (e.g. X) |
611 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. | 625 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. |
612 UpdateDisplay("400x400,800x800*2"); | 626 UpdateDisplay("400x400,800x800*2"); |
613 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 627 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
614 ASSERT_EQ(2U, root_windows.size()); | 628 ASSERT_EQ(2U, root_windows.size()); |
615 | 629 |
616 test::CursorManagerTestApi cursor_test_api( | 630 test::CursorManagerTestApi cursor_test_api( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 ASSERT_TRUE(resizer.get()); | 667 ASSERT_TRUE(resizer.get()); |
654 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0); | 668 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0); |
655 TestIfMouseWarpsAt(gfx::Point(400, 200)); | 669 TestIfMouseWarpsAt(gfx::Point(400, 200)); |
656 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); | 670 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); |
657 resizer->CompleteDrag(); | 671 resizer->CompleteDrag(); |
658 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); | 672 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); |
659 } | 673 } |
660 } | 674 } |
661 | 675 |
662 // Verifies several kinds of windows can be moved across displays. | 676 // Verifies several kinds of windows can be moved across displays. |
663 TEST_F(DragWindowResizerTest, MoveWindowAcrossDisplays) { | 677 TEST_P(DragWindowResizerTest, MoveWindowAcrossDisplays) { |
664 if (!SupportsMultipleDisplays()) | 678 if (!SupportsMultipleDisplays()) |
665 return; | 679 return; |
666 | 680 |
667 // The secondary display is logically on the right, but on the system (e.g. X) | 681 // The secondary display is logically on the right, but on the system (e.g. X) |
668 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. | 682 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. |
669 UpdateDisplay("400x400,400x400"); | 683 UpdateDisplay("400x400,400x400"); |
670 | 684 |
671 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 685 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
672 ASSERT_EQ(2U, root_windows.size()); | 686 ASSERT_EQ(2U, root_windows.size()); |
673 | 687 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 ASSERT_TRUE(resizer.get()); | 783 ASSERT_TRUE(resizer.get()); |
770 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); | 784 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); |
771 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200))); | 785 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200))); |
772 EXPECT_EQ("401,200", | 786 EXPECT_EQ("401,200", |
773 aura::Env::GetInstance()->last_mouse_location().ToString()); | 787 aura::Env::GetInstance()->last_mouse_location().ToString()); |
774 resizer->CompleteDrag(); | 788 resizer->CompleteDrag(); |
775 } | 789 } |
776 } | 790 } |
777 | 791 |
778 } // namespace ash | 792 } // namespace ash |
OLD | NEW |