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/workspace/workspace_window_resizer.h" | 5 #include "ash/wm/workspace/workspace_window_resizer.h" |
6 | 6 |
7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
8 #include "ash/display/mouse_cursor_event_filter.h" | |
9 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
10 #include "ash/screen_ash.h" | 9 #include "ash/screen_ash.h" |
11 #include "ash/shell.h" | 10 #include "ash/shell.h" |
12 #include "ash/shell_window_ids.h" | 11 #include "ash/shell_window_ids.h" |
13 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
14 #include "ash/test/cursor_manager_test_api.h" | |
15 #include "ash/wm/cursor_manager.h" | |
16 #include "ash/wm/drag_window_controller.h" | |
17 #include "ash/wm/property_util.h" | 13 #include "ash/wm/property_util.h" |
18 #include "ash/wm/shelf_layout_manager.h" | 14 #include "ash/wm/shelf_layout_manager.h" |
19 #include "ash/wm/window_util.h" | 15 #include "ash/wm/window_util.h" |
20 #include "ash/wm/workspace/phantom_window_controller.h" | 16 #include "ash/wm/workspace/phantom_window_controller.h" |
21 #include "ash/wm/workspace/snap_sizer.h" | 17 #include "ash/wm/workspace/snap_sizer.h" |
22 #include "ash/wm/workspace_controller.h" | 18 #include "ash/wm/workspace_controller.h" |
23 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
24 #include "base/stringprintf.h" | 20 #include "base/stringprintf.h" |
25 #include "ui/aura/client/aura_constants.h" | 21 #include "ui/aura/client/aura_constants.h" |
26 #include "ui/aura/root_window.h" | 22 #include "ui/aura/root_window.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 result += base::IntToString((*i)->id()); | 124 result += base::IntToString((*i)->id()); |
129 } | 125 } |
130 } | 126 } |
131 return result; | 127 return result; |
132 } | 128 } |
133 | 129 |
134 protected: | 130 protected: |
135 gfx::Point CalculateDragPoint(const WorkspaceWindowResizer& resizer, | 131 gfx::Point CalculateDragPoint(const WorkspaceWindowResizer& resizer, |
136 int delta_x, | 132 int delta_x, |
137 int delta_y) const { | 133 int delta_y) const { |
138 gfx::Point location = resizer.initial_location_in_parent(); | 134 gfx::Point location = resizer.GetInitialLocationInParentForTest(); |
139 location.set_x(location.x() + delta_x); | 135 location.set_x(location.x() + delta_x); |
140 location.set_y(location.y() + delta_y); | 136 location.set_y(location.y() + delta_y); |
141 return location; | 137 return location; |
142 } | 138 } |
143 | 139 |
144 std::vector<aura::Window*> empty_windows() const { | 140 std::vector<aura::Window*> empty_windows() const { |
145 return std::vector<aura::Window*>(); | 141 return std::vector<aura::Window*>(); |
146 } | 142 } |
147 | 143 |
148 internal::ShelfLayoutManager* shelf_layout_manager() { | 144 internal::ShelfLayoutManager* shelf_layout_manager() { |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 window_->SetProperty(aura::client::kCanResizeKey, false); | 510 window_->SetProperty(aura::client::kCanResizeKey, false); |
515 | 511 |
516 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 512 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
517 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | 513 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
518 ASSERT_TRUE(resizer.get()); | 514 ASSERT_TRUE(resizer.get()); |
519 resizer->Drag(CalculateDragPoint(*resizer, -20, 0), 0); | 515 resizer->Drag(CalculateDragPoint(*resizer, -20, 0), 0); |
520 resizer->CompleteDrag(0); | 516 resizer->CompleteDrag(0); |
521 EXPECT_EQ("0,30 50x60", window_->bounds().ToString()); | 517 EXPECT_EQ("0,30 50x60", window_->bounds().ToString()); |
522 } | 518 } |
523 | 519 |
524 // Verifies a window can be moved from the primary display to another. | |
525 TEST_F(WorkspaceWindowResizerTest, WindowDragWithMultiDisplays) { | |
526 // The secondary display is logically on the right, but on the system (e.g. X) | |
527 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. | |
528 UpdateDisplay("800x600,800x600"); | |
529 shelf_layout_manager()->LayoutShelf(); | |
530 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | |
531 ASSERT_EQ(2U, root_windows.size()); | |
532 | |
533 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), | |
534 Shell::GetScreen()->GetPrimaryDisplay()); | |
535 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | |
536 { | |
537 // Grab (0, 0) of the window. | |
538 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | |
539 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | |
540 ASSERT_TRUE(resizer.get()); | |
541 // Drag the pointer to the right. Once it reaches the right edge of the | |
542 // primary display, it warps to the secondary. | |
543 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); | |
544 resizer->CompleteDrag(0); | |
545 // The whole window is on the secondary display now. The parent should be | |
546 // changed. | |
547 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | |
548 EXPECT_EQ("0,10 50x60", window_->bounds().ToString()); | |
549 } | |
550 | |
551 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), | |
552 Shell::GetScreen()->GetPrimaryDisplay()); | |
553 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | |
554 { | |
555 // Grab (0, 0) of the window and move the pointer to (790, 10). | |
556 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | |
557 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | |
558 ASSERT_TRUE(resizer.get()); | |
559 resizer->Drag(CalculateDragPoint(*resizer, 790, 10), 0); | |
560 resizer->CompleteDrag(0); | |
561 // Since the pointer is still on the primary root window, the parent should | |
562 // not be changed. | |
563 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | |
564 EXPECT_EQ("790,10 50x60", window_->bounds().ToString()); | |
565 } | |
566 | |
567 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), | |
568 Shell::GetScreen()->GetPrimaryDisplay()); | |
569 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | |
570 { | |
571 // Grab the top-right edge of the window and move the pointer to (0, 10) | |
572 // in the secondary root window's coordinates. | |
573 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | |
574 window_.get(), gfx::Point(49, 0), HTCAPTION, empty_windows())); | |
575 ASSERT_TRUE(resizer.get()); | |
576 resizer->Drag(CalculateDragPoint(*resizer, 751, 10), ui::EF_CONTROL_DOWN); | |
577 resizer->CompleteDrag(0); | |
578 // Since the pointer is on the secondary, the parent should be changed | |
579 // even though only small fraction of the window is within the secondary | |
580 // root window's bounds. | |
581 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | |
582 EXPECT_EQ("-49,10 50x60", window_->bounds().ToString()); | |
583 } | |
584 } | |
585 | |
586 // Verifies a window can be moved from the secondary display to primary. | |
587 TEST_F(WorkspaceWindowResizerTest, | |
588 WindowDragWithMultiDisplaysRightToLeft) { | |
589 UpdateDisplay("800x600,800x600"); | |
590 shelf_layout_manager()->LayoutShelf(); | |
591 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | |
592 ASSERT_EQ(2U, root_windows.size()); | |
593 | |
594 window_->SetBoundsInScreen( | |
595 gfx::Rect(800, 00, 50, 60), | |
596 Shell::GetScreen()->GetDisplayNearestWindow(root_windows[1])); | |
597 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | |
598 { | |
599 // Grab (0, 0) of the window. | |
600 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | |
601 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | |
602 ASSERT_TRUE(resizer.get()); | |
603 // Move the mouse near the right edge, (798, 0), of the primary display. | |
604 resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN); | |
605 resizer->CompleteDrag(0); | |
606 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | |
607 EXPECT_EQ("798,0 50x60", window_->bounds().ToString()); | |
608 } | |
609 } | |
610 | |
611 // Verifies the drag window controller is instanciated appropriately. | |
612 TEST_F(WorkspaceWindowResizerTest, DragWindowController) { | |
613 UpdateDisplay("800x600,800x600"); | |
614 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | |
615 ASSERT_EQ(2U, root_windows.size()); | |
616 | |
617 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), | |
618 Shell::GetScreen()->GetPrimaryDisplay()); | |
619 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | |
620 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); | |
621 { | |
622 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | |
623 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | |
624 ASSERT_TRUE(resizer.get()); | |
625 EXPECT_FALSE(resizer->snap_phantom_window_controller_.get()); | |
626 EXPECT_FALSE(resizer->drag_window_controller_.get()); | |
627 | |
628 // The pointer is inside the primary root. Both phantoms should be NULL. | |
629 resizer->Drag(CalculateDragPoint(*resizer, 10, 10), 0); | |
630 EXPECT_FALSE(resizer->snap_phantom_window_controller_.get()); | |
631 EXPECT_FALSE(resizer->drag_window_controller_.get()); | |
632 | |
633 // The window spans both root windows. | |
634 resizer->Drag(CalculateDragPoint(*resizer, 798, 10), 0); | |
635 EXPECT_FALSE(resizer->snap_phantom_window_controller_.get()); | |
636 DragWindowController* controller = | |
637 resizer->drag_window_controller_.get(); | |
638 ASSERT_TRUE(controller); | |
639 ASSERT_TRUE(controller->drag_widget_); | |
640 ui::Layer* drag_layer = | |
641 controller->drag_widget_->GetNativeWindow()->layer(); | |
642 ASSERT_TRUE(drag_layer); | |
643 | |
644 // Check if |resizer->layer_| is properly set to the phantom widget. | |
645 const std::vector<ui::Layer*>& layers = drag_layer->children(); | |
646 EXPECT_FALSE(layers.empty()); | |
647 EXPECT_EQ(controller->layer_, layers.back()); | |
648 | |
649 // |window_| should be opaque since the pointer is still on the primary | |
650 // root window. The phantom should be semi-transparent. | |
651 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); | |
652 EXPECT_GT(1.0f, drag_layer->opacity()); | |
653 | |
654 // Enter the pointer to the secondary display. | |
655 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); | |
656 EXPECT_FALSE(resizer->snap_phantom_window_controller_.get()); | |
657 controller = resizer->drag_window_controller_.get(); | |
658 ASSERT_TRUE(controller); | |
659 // |window_| should be transparent, and the phantom should be opaque. | |
660 EXPECT_GT(1.0f, window_->layer()->opacity()); | |
661 EXPECT_FLOAT_EQ(1.0f, drag_layer->opacity()); | |
662 | |
663 resizer->CompleteDrag(0); | |
664 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | |
665 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); | |
666 } | |
667 | |
668 // Do the same test with RevertDrag(). | |
669 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), | |
670 Shell::GetScreen()->GetPrimaryDisplay()); | |
671 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | |
672 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); | |
673 { | |
674 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | |
675 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | |
676 ASSERT_TRUE(resizer.get()); | |
677 EXPECT_FALSE(resizer->snap_phantom_window_controller_.get()); | |
678 EXPECT_FALSE(resizer->drag_window_controller_.get()); | |
679 | |
680 resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0); | |
681 resizer->RevertDrag(); | |
682 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | |
683 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); | |
684 } | |
685 } | |
686 | |
687 // Verifies the style of the drag phantom window is correct. | |
688 TEST_F(WorkspaceWindowResizerTest, CancelSnapPhantom) { | 520 TEST_F(WorkspaceWindowResizerTest, CancelSnapPhantom) { |
689 UpdateDisplay("800x600,800x600"); | 521 UpdateDisplay("800x600,800x600"); |
690 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 522 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
691 ASSERT_EQ(2U, root_windows.size()); | 523 ASSERT_EQ(2U, root_windows.size()); |
692 | 524 |
693 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), | 525 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), |
694 Shell::GetScreen()->GetPrimaryDisplay()); | 526 Shell::GetScreen()->GetPrimaryDisplay()); |
695 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 527 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
696 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); | 528 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); |
697 { | 529 { |
698 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 530 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
699 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | 531 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
700 ASSERT_TRUE(resizer.get()); | 532 ASSERT_TRUE(resizer.get()); |
701 EXPECT_FALSE(resizer->snap_phantom_window_controller_.get()); | 533 EXPECT_FALSE(resizer->snap_phantom_window_controller_.get()); |
702 EXPECT_FALSE(resizer->drag_window_controller_.get()); | |
703 EXPECT_EQ(WorkspaceWindowResizer::SNAP_NONE, resizer->snap_type_); | |
704 | 534 |
705 // The pointer is on the edge but not shared. Both controllers should be | 535 // The pointer is on the edge but not shared. The snap phantom window |
706 // non-NULL. | 536 // controller should be non-NULL. |
707 resizer->Drag(CalculateDragPoint(*resizer, 799, 0), 0); | 537 resizer->Drag(CalculateDragPoint(*resizer, 799, 0), 0); |
708 EXPECT_TRUE(resizer->snap_phantom_window_controller_.get()); | 538 EXPECT_TRUE(resizer->snap_phantom_window_controller_.get()); |
709 EXPECT_EQ(WorkspaceWindowResizer::SNAP_RIGHT_EDGE, resizer->snap_type_); | |
710 DragWindowController* controller = | |
711 resizer->drag_window_controller_.get(); | |
712 ASSERT_TRUE(controller); | |
713 | 539 |
714 // Move the cursor across the edge. Now the snap phantom controller | 540 // Move the cursor across the edge. Now the snap phantom window controller |
715 // should be canceled. | 541 // should be canceled. |
716 resizer->Drag(CalculateDragPoint(*resizer, 800, 0), 0); | 542 resizer->Drag(CalculateDragPoint(*resizer, 800, 0), 0); |
717 EXPECT_FALSE(resizer->snap_phantom_window_controller_.get()); | 543 EXPECT_FALSE(resizer->snap_phantom_window_controller_.get()); |
718 EXPECT_EQ(WorkspaceWindowResizer::SNAP_NONE, resizer->snap_type_); | |
719 controller = | |
720 resizer->drag_window_controller_.get(); | |
721 ASSERT_TRUE(controller); | |
722 } | 544 } |
723 } | 545 } |
724 | 546 |
725 // Verifies if the resizer sets and resets | |
726 // MouseCursorEventFilter::mouse_warp_mode_ as expected. | |
727 TEST_F(WorkspaceWindowResizerTest, WarpMousePointer) { | |
728 MouseCursorEventFilter* event_filter = | |
729 Shell::GetInstance()->mouse_cursor_filter(); | |
730 ASSERT_TRUE(event_filter); | |
731 window_->SetBounds(gfx::Rect(0, 0, 50, 60)); | |
732 | |
733 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS, | |
734 event_filter->mouse_warp_mode_); | |
735 { | |
736 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | |
737 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | |
738 // While dragging a window, warp should be allowed. | |
739 EXPECT_EQ(MouseCursorEventFilter::WARP_DRAG, | |
740 event_filter->mouse_warp_mode_); | |
741 resizer->CompleteDrag(0); | |
742 } | |
743 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS, | |
744 event_filter->mouse_warp_mode_); | |
745 | |
746 { | |
747 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | |
748 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | |
749 EXPECT_EQ(MouseCursorEventFilter::WARP_DRAG, | |
750 event_filter->mouse_warp_mode_); | |
751 resizer->RevertDrag(); | |
752 } | |
753 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS, | |
754 event_filter->mouse_warp_mode_); | |
755 | |
756 { | |
757 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | |
758 window_.get(), gfx::Point(), HTRIGHT, empty_windows())); | |
759 // While resizing a window, warp should NOT be allowed. | |
760 EXPECT_EQ(MouseCursorEventFilter::WARP_NONE, | |
761 event_filter->mouse_warp_mode_); | |
762 resizer->CompleteDrag(0); | |
763 } | |
764 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS, | |
765 event_filter->mouse_warp_mode_); | |
766 | |
767 { | |
768 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | |
769 window_.get(), gfx::Point(), HTRIGHT, empty_windows())); | |
770 EXPECT_EQ(MouseCursorEventFilter::WARP_NONE, | |
771 event_filter->mouse_warp_mode_); | |
772 resizer->RevertDrag(); | |
773 } | |
774 EXPECT_EQ(MouseCursorEventFilter::WARP_ALWAYS, | |
775 event_filter->mouse_warp_mode_); | |
776 } | |
777 | |
778 // Verifies windows are correctly restacked when reordering multiple windows. | 547 // Verifies windows are correctly restacked when reordering multiple windows. |
779 TEST_F(WorkspaceWindowResizerTest, RestackAttached) { | 548 TEST_F(WorkspaceWindowResizerTest, RestackAttached) { |
780 window_->SetBounds(gfx::Rect( 0, 0, 200, 300)); | 549 window_->SetBounds(gfx::Rect( 0, 0, 200, 300)); |
781 window2_->SetBounds(gfx::Rect(200, 0, 100, 200)); | 550 window2_->SetBounds(gfx::Rect(200, 0, 100, 200)); |
782 window3_->SetBounds(gfx::Rect(300, 0, 100, 100)); | 551 window3_->SetBounds(gfx::Rect(300, 0, 100, 100)); |
783 | 552 |
784 { | 553 { |
785 std::vector<aura::Window*> windows; | 554 std::vector<aura::Window*> windows; |
786 windows.push_back(window2_.get()); | 555 windows.push_back(window2_.get()); |
787 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 556 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1362 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1131 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
1363 window2_->Show(); | 1132 window2_->Show(); |
1364 | 1133 |
1365 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1134 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
1366 window_.get(), gfx::Point(), HTLEFT, empty_windows())); | 1135 window_.get(), gfx::Point(), HTLEFT, empty_windows())); |
1367 ASSERT_TRUE(resizer.get()); | 1136 ASSERT_TRUE(resizer.get()); |
1368 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1137 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
1369 EXPECT_EQ("99,200 21x30", window_->bounds().ToString()); | 1138 EXPECT_EQ("99,200 21x30", window_->bounds().ToString()); |
1370 } | 1139 } |
1371 | 1140 |
1372 // Verifies cursor's device scale factor is updated whe a window is moved across | |
1373 // root windows with different device scale factors (http://crbug.com/154183). | |
1374 TEST_F(WorkspaceWindowResizerTest, CursorDeviceScaleFactor) { | |
1375 // The secondary display is logically on the right, but on the system (e.g. X) | |
1376 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. | |
1377 UpdateDisplay("400x400,800x800*2"); | |
1378 shelf_layout_manager()->LayoutShelf(); | |
1379 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | |
1380 ASSERT_EQ(2U, root_windows.size()); | |
1381 | |
1382 test::CursorManagerTestApi cursor_test_api( | |
1383 Shell::GetInstance()->cursor_manager()); | |
1384 MouseCursorEventFilter* event_filter = | |
1385 Shell::GetInstance()->mouse_cursor_filter(); | |
1386 // Move window from the root window with 1.0 device scale factor to the root | |
1387 // window with 2.0 device scale factor. | |
1388 { | |
1389 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), | |
1390 Shell::GetScreen()->GetPrimaryDisplay()); | |
1391 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | |
1392 // Grab (0, 0) of the window. | |
1393 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | |
1394 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | |
1395 EXPECT_EQ(1.0f, cursor_test_api.GetDeviceScaleFactor()); | |
1396 ASSERT_TRUE(resizer.get()); | |
1397 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); | |
1398 event_filter->WarpMouseCursorIfNecessary(root_windows[0], | |
1399 gfx::Point(399, 200)); | |
1400 EXPECT_EQ(2.0f, cursor_test_api.GetDeviceScaleFactor()); | |
1401 resizer->CompleteDrag(0); | |
1402 EXPECT_EQ(2.0f, cursor_test_api.GetDeviceScaleFactor()); | |
1403 } | |
1404 | |
1405 // Move window from the root window with 2.0 device scale factor to the root | |
1406 // window with 1.0 device scale factor. | |
1407 { | |
1408 window_->SetBoundsInScreen( | |
1409 gfx::Rect(600, 0, 50, 60), | |
1410 Shell::GetScreen()->GetDisplayNearestWindow(root_windows[1])); | |
1411 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | |
1412 // Grab (0, 0) of the window. | |
1413 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | |
1414 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | |
1415 EXPECT_EQ(2.0f, cursor_test_api.GetDeviceScaleFactor()); | |
1416 ASSERT_TRUE(resizer.get()); | |
1417 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0); | |
1418 event_filter->WarpMouseCursorIfNecessary(root_windows[1], | |
1419 gfx::Point(400, 200)); | |
1420 EXPECT_EQ(1.0f, cursor_test_api.GetDeviceScaleFactor()); | |
1421 resizer->CompleteDrag(0); | |
1422 EXPECT_EQ(1.0f, cursor_test_api.GetDeviceScaleFactor()); | |
1423 } | |
1424 } | |
1425 | |
1426 // Test that the user user moved window flag is getting properly set. | 1141 // Test that the user user moved window flag is getting properly set. |
1427 TEST_F(WorkspaceWindowResizerTest, CheckUserWindowMangedFlags) { | 1142 TEST_F(WorkspaceWindowResizerTest, CheckUserWindowMangedFlags) { |
1428 window_->SetBounds(gfx::Rect( 0, 50, 400, 200)); | 1143 window_->SetBounds(gfx::Rect( 0, 50, 400, 200)); |
1429 | 1144 |
1430 std::vector<aura::Window*> no_attached_windows; | 1145 std::vector<aura::Window*> no_attached_windows; |
1431 // Check that an abort doesn't change anything. | 1146 // Check that an abort doesn't change anything. |
1432 { | 1147 { |
1433 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1148 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
1434 window_.get(), gfx::Point(), HTCAPTION, no_attached_windows)); | 1149 window_.get(), gfx::Point(), HTCAPTION, no_attached_windows)); |
1435 ASSERT_TRUE(resizer.get()); | 1150 ASSERT_TRUE(resizer.get()); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1722 ASSERT_TRUE(resizer.get()); | 1437 ASSERT_TRUE(resizer.get()); |
1723 // Move it 50 to the left, which should contract w1 and expand w2-3. | 1438 // Move it 50 to the left, which should contract w1 and expand w2-3. |
1724 resizer->Drag(CalculateDragPoint(*resizer, -50, 0), 0); | 1439 resizer->Drag(CalculateDragPoint(*resizer, -50, 0), 0); |
1725 EXPECT_EQ("100,100 98x100", window_->bounds().ToString()); | 1440 EXPECT_EQ("100,100 98x100", window_->bounds().ToString()); |
1726 EXPECT_EQ("198,100 101x100", window2_->bounds().ToString()); | 1441 EXPECT_EQ("198,100 101x100", window2_->bounds().ToString()); |
1727 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); | 1442 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); |
1728 } | 1443 } |
1729 | 1444 |
1730 } // namespace internal | 1445 } // namespace internal |
1731 } // namespace ash | 1446 } // namespace ash |
OLD | NEW |