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

Side by Side Diff: ash/wm/drag_window_resizer_unittest.cc

Issue 2653593004: chromeos: Remove AshTestBase::SupportsMultipleDisplays (Closed)
Patch Set: 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/wm/drag_window_resizer.h" 5 #include "ash/wm/drag_window_resizer.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/shelf/shelf_layout_manager.h" 8 #include "ash/common/shelf/shelf_layout_manager.h"
9 #include "ash/common/wm/window_positioning_utils.h" 9 #include "ash/common/wm/window_positioning_utils.h"
10 #include "ash/common/wm_window.h" 10 #include "ash/common/wm_window.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 INSTANTIATE_TEST_CASE_P( 173 INSTANTIATE_TEST_CASE_P(
174 /* prefix intentionally left blank due to only one parameterization */, 174 /* prefix intentionally left blank due to only one parameterization */,
175 DragWindowResizerTest, 175 DragWindowResizerTest,
176 testing::Values(MaterialDesignController::NON_MATERIAL, 176 testing::Values(MaterialDesignController::NON_MATERIAL,
177 MaterialDesignController::MATERIAL_NORMAL, 177 MaterialDesignController::MATERIAL_NORMAL,
178 MaterialDesignController::MATERIAL_EXPERIMENTAL)); 178 MaterialDesignController::MATERIAL_EXPERIMENTAL));
179 179
180 // Verifies a window can be moved from the primary display to another. 180 // Verifies a window can be moved from the primary display to another.
181 TEST_P(DragWindowResizerTest, WindowDragWithMultiDisplays) { 181 TEST_P(DragWindowResizerTest, WindowDragWithMultiDisplays) {
182 if (!SupportsMultipleDisplays())
183 return;
184 const int height_offset = GetMdMaximizedWindowHeightOffset(); 182 const int height_offset = GetMdMaximizedWindowHeightOffset();
185 183
186 // The secondary display is logically on the right, but on the system (e.g. X) 184 // The secondary display is logically on the right, but on the system (e.g. X)
187 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. 185 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
188 UpdateDisplay("800x600,400x300"); 186 UpdateDisplay("800x600,400x300");
189 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 187 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
190 ASSERT_EQ(2U, root_windows.size()); 188 ASSERT_EQ(2U, root_windows.size());
191 189
192 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 190 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
193 display::Screen::GetScreen()->GetPrimaryDisplay()); 191 display::Screen::GetScreen()->GetPrimaryDisplay());
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 intersect.Intersect(window_bounds_in_screen); 295 intersect.Intersect(window_bounds_in_screen);
298 EXPECT_LE(10, intersect.width()); 296 EXPECT_LE(10, intersect.width());
299 EXPECT_LE(10, intersect.height()); 297 EXPECT_LE(10, intersect.height());
300 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(850, 10))); 298 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(850, 10)));
301 } 299 }
302 } 300 }
303 301
304 // Verifies that dragging the active window to another display makes the new 302 // Verifies that dragging the active window to another display makes the new
305 // root window the active root window. 303 // root window the active root window.
306 TEST_P(DragWindowResizerTest, WindowDragWithMultiDisplaysActiveRoot) { 304 TEST_P(DragWindowResizerTest, WindowDragWithMultiDisplaysActiveRoot) {
307 if (!SupportsMultipleDisplays())
308 return;
309
310 // The secondary display is logically on the right, but on the system (e.g. X) 305 // The secondary display is logically on the right, but on the system (e.g. X)
311 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. 306 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
312 UpdateDisplay("800x600,800x600"); 307 UpdateDisplay("800x600,800x600");
313 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 308 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
314 ASSERT_EQ(2U, root_windows.size()); 309 ASSERT_EQ(2U, root_windows.size());
315 310
316 aura::test::TestWindowDelegate delegate; 311 aura::test::TestWindowDelegate delegate;
317 std::unique_ptr<aura::Window> window(new aura::Window(&delegate)); 312 std::unique_ptr<aura::Window> window(new aura::Window(&delegate));
318 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); 313 window->SetType(ui::wm::WINDOW_TYPE_NORMAL);
319 window->Init(ui::LAYER_TEXTURED); 314 window->Init(ui::LAYER_TEXTURED);
(...skipping 16 matching lines...) Expand all
336 resizer->CompleteDrag(); 331 resizer->CompleteDrag();
337 // The whole window is on the secondary display now. The parent should be 332 // The whole window is on the secondary display now. The parent should be
338 // changed. 333 // changed.
339 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 334 EXPECT_EQ(root_windows[1], window->GetRootWindow());
340 EXPECT_EQ(root_windows[1], ash::Shell::GetTargetRootWindow()); 335 EXPECT_EQ(root_windows[1], ash::Shell::GetTargetRootWindow());
341 } 336 }
342 } 337 }
343 338
344 // Verifies a window can be moved from the secondary display to primary. 339 // Verifies a window can be moved from the secondary display to primary.
345 TEST_P(DragWindowResizerTest, WindowDragWithMultiDisplaysRightToLeft) { 340 TEST_P(DragWindowResizerTest, WindowDragWithMultiDisplaysRightToLeft) {
346 if (!SupportsMultipleDisplays())
347 return;
348
349 UpdateDisplay("800x600,800x600"); 341 UpdateDisplay("800x600,800x600");
350 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 342 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
351 ASSERT_EQ(2U, root_windows.size()); 343 ASSERT_EQ(2U, root_windows.size());
352 344
353 window_->SetBoundsInScreen( 345 window_->SetBoundsInScreen(
354 gfx::Rect(800, 00, 50, 60), 346 gfx::Rect(800, 00, 50, 60),
355 display::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1])); 347 display::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1]));
356 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 348 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
357 { 349 {
358 // Grab (0, 0) of the window. 350 // Grab (0, 0) of the window.
359 std::unique_ptr<WindowResizer> resizer( 351 std::unique_ptr<WindowResizer> resizer(
360 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION)); 352 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION));
361 ASSERT_TRUE(resizer.get()); 353 ASSERT_TRUE(resizer.get());
362 // Move the mouse near the right edge, (798, 0), of the primary display. 354 // Move the mouse near the right edge, (798, 0), of the primary display.
363 resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN); 355 resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN);
364 resizer->CompleteDrag(); 356 resizer->CompleteDrag();
365 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 357 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
366 // Window origin should be adjusted for minimum visibility (25px). 358 // Window origin should be adjusted for minimum visibility (25px).
367 EXPECT_EQ("775,0 50x60", window_->bounds().ToString()); 359 EXPECT_EQ("775,0 50x60", window_->bounds().ToString());
368 } 360 }
369 } 361 }
370 362
371 // Verifies the drag window is shown correctly. 363 // Verifies the drag window is shown correctly.
372 TEST_P(DragWindowResizerTest, DragWindowController) { 364 TEST_P(DragWindowResizerTest, DragWindowController) {
373 if (!SupportsMultipleDisplays())
374 return;
375
376 UpdateDisplay("800x600,800x600"); 365 UpdateDisplay("800x600,800x600");
377 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 366 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
378 ASSERT_EQ(2U, root_windows.size()); 367 ASSERT_EQ(2U, root_windows.size());
379 368
380 TestLayerDelegate delegate; 369 TestLayerDelegate delegate;
381 window_->layer()->set_delegate(&delegate); 370 window_->layer()->set_delegate(&delegate);
382 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 371 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
383 display::Screen::GetScreen()->GetPrimaryDisplay()); 372 display::Screen::GetScreen()->GetPrimaryDisplay());
384 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 373 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
385 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 374 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 EXPECT_FALSE(controller); 445 EXPECT_FALSE(controller);
457 446
458 resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0); 447 resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0);
459 resizer->RevertDrag(); 448 resizer->RevertDrag();
460 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 449 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
461 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 450 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
462 } 451 }
463 } 452 }
464 453
465 TEST_P(DragWindowResizerTest, DragWindowControllerAcrossThreeDisplays) { 454 TEST_P(DragWindowResizerTest, DragWindowControllerAcrossThreeDisplays) {
466 if (!SupportsMultipleDisplays())
467 return;
468
469 UpdateDisplay("400x600,400x600,800x600"); 455 UpdateDisplay("400x600,400x600,800x600");
470 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 456 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
471 457
472 // Layout so that all three displays touch each other. 458 // Layout so that all three displays touch each other.
473 display::DisplayIdList list = display_manager()->GetCurrentDisplayIdList(); 459 display::DisplayIdList list = display_manager()->GetCurrentDisplayIdList();
474 ASSERT_EQ(3u, list.size()); 460 ASSERT_EQ(3u, list.size());
475 ASSERT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().id(), list[0]); 461 ASSERT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().id(), list[0]);
476 display::DisplayLayoutBuilder builder(list[0]); 462 display::DisplayLayoutBuilder builder(list[0]);
477 builder.AddDisplayPlacement(list[1], list[0], 463 builder.AddDisplayPlacement(list[1], list[0],
478 display::DisplayPlacement::RIGHT, 0); 464 display::DisplayPlacement::RIGHT, 0);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 CreateDragWindowResizer(window_.get(), gfx::Point(), HTRIGHT)); 589 CreateDragWindowResizer(window_.get(), gfx::Point(), HTRIGHT));
604 EXPECT_FALSE(event_filter->mouse_warp_enabled_); 590 EXPECT_FALSE(event_filter->mouse_warp_enabled_);
605 resizer->RevertDrag(); 591 resizer->RevertDrag();
606 } 592 }
607 EXPECT_TRUE(event_filter->mouse_warp_enabled_); 593 EXPECT_TRUE(event_filter->mouse_warp_enabled_);
608 } 594 }
609 595
610 // Verifies cursor's device scale factor is updated whe a window is moved across 596 // Verifies cursor's device scale factor is updated whe a window is moved across
611 // root windows with different device scale factors (http://crbug.com/154183). 597 // root windows with different device scale factors (http://crbug.com/154183).
612 TEST_P(DragWindowResizerTest, CursorDeviceScaleFactor) { 598 TEST_P(DragWindowResizerTest, CursorDeviceScaleFactor) {
613 if (!SupportsMultipleDisplays())
614 return;
615
616 // The secondary display is logically on the right, but on the system (e.g. X) 599 // The secondary display is logically on the right, but on the system (e.g. X)
617 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. 600 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
618 UpdateDisplay("400x400,800x800*2"); 601 UpdateDisplay("400x400,800x800*2");
619 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 602 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
620 ASSERT_EQ(2U, root_windows.size()); 603 ASSERT_EQ(2U, root_windows.size());
621 604
622 test::CursorManagerTestApi cursor_test_api( 605 test::CursorManagerTestApi cursor_test_api(
623 Shell::GetInstance()->cursor_manager()); 606 Shell::GetInstance()->cursor_manager());
624 // Move window from the root window with 1.0 device scale factor to the root 607 // Move window from the root window with 1.0 device scale factor to the root
625 // window with 2.0 device scale factor. 608 // window with 2.0 device scale factor.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0); 643 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0);
661 TestIfMouseWarpsAt(gfx::Point(400, 200)); 644 TestIfMouseWarpsAt(gfx::Point(400, 200));
662 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 645 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
663 resizer->CompleteDrag(); 646 resizer->CompleteDrag();
664 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 647 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
665 } 648 }
666 } 649 }
667 650
668 // Verifies several kinds of windows can be moved across displays. 651 // Verifies several kinds of windows can be moved across displays.
669 TEST_P(DragWindowResizerTest, MoveWindowAcrossDisplays) { 652 TEST_P(DragWindowResizerTest, MoveWindowAcrossDisplays) {
670 if (!SupportsMultipleDisplays())
671 return;
672
673 // The secondary display is logically on the right, but on the system (e.g. X) 653 // The secondary display is logically on the right, but on the system (e.g. X)
674 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. 654 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
675 UpdateDisplay("400x400,400x400"); 655 UpdateDisplay("400x400,400x400");
676 656
677 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 657 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
678 ASSERT_EQ(2U, root_windows.size()); 658 ASSERT_EQ(2U, root_windows.size());
679 659
680 // Normal window can be moved across display. 660 // Normal window can be moved across display.
681 { 661 {
682 aura::Window* window = window_.get(); 662 aura::Window* window = window_.get();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 ASSERT_TRUE(resizer.get()); 755 ASSERT_TRUE(resizer.get());
776 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 756 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
777 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200))); 757 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200)));
778 EXPECT_EQ("401,200", 758 EXPECT_EQ("401,200",
779 aura::Env::GetInstance()->last_mouse_location().ToString()); 759 aura::Env::GetInstance()->last_mouse_location().ToString());
780 resizer->CompleteDrag(); 760 resizer->CompleteDrag();
781 } 761 }
782 } 762 }
783 763
784 } // namespace ash 764 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/dock/docked_window_resizer_unittest.cc ('k') | ash/wm/immersive_fullscreen_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698