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

Side by Side Diff: ash/wm/workspace/workspace_window_resizer_unittest.cc

Issue 68033003: Undocks window first before side-snapping bounds (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Undocks window first before side-snapping bounds (comments) Created 7 years 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/workspace/workspace_window_resizer.h" 5 #include "ash/wm/workspace/workspace_window_resizer.h"
6 6
7 #include "ash/ash_constants.h" 7 #include "ash/ash_constants.h"
8 #include "ash/ash_switches.h" 8 #include "ash/ash_switches.h"
9 #include "ash/display/display_manager.h" 9 #include "ash/display/display_manager.h"
10 #include "ash/root_window_controller.h" 10 #include "ash/root_window_controller.h"
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); 630 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0);
631 resizer->CompleteDrag(0); 631 resizer->CompleteDrag(0);
632 EXPECT_EQ(expected_bounds.ToString(), window_->bounds().ToString()); 632 EXPECT_EQ(expected_bounds.ToString(), window_->bounds().ToString());
633 ASSERT_TRUE(window_state->HasRestoreBounds()); 633 ASSERT_TRUE(window_state->HasRestoreBounds());
634 EXPECT_EQ("20,30 400x60", 634 EXPECT_EQ("20,30 400x60",
635 window_state->GetRestoreBoundsInScreen().ToString()); 635 window_state->GetRestoreBoundsInScreen().ToString());
636 } 636 }
637 637
638 // Test if the restore bounds is correct in multiple displays. 638 // Test if the restore bounds is correct in multiple displays.
639 window_state->ClearRestoreBounds(); 639 window_state->ClearRestoreBounds();
640 // Restore to clear snapped state.
641 window_state->Restore();
640 642
641 if (!SupportsMultipleDisplays()) 643 if (!SupportsMultipleDisplays())
642 return; 644 return;
643 645
644 UpdateDisplay("800x600,500x600"); 646 UpdateDisplay("800x600,500x600");
645 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 647 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
646 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 648 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
647 // Window is wide enough not to get docked right away. 649 // Window is wide enough not to get docked right away.
648 window_->SetBoundsInScreen(gfx::Rect(800, 10, 400, 60), 650 window_->SetBoundsInScreen(gfx::Rect(800, 10, 400, 60),
649 ScreenAsh::GetSecondaryDisplay()); 651 ScreenAsh::GetSecondaryDisplay());
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); 778 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0));
777 779
778 // Positions the secondary display at the bottom the primary display. 780 // Positions the secondary display at the bottom the primary display.
779 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( 781 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays(
780 ash::DisplayLayout(ash::DisplayLayout::BOTTOM, 0)); 782 ash::DisplayLayout(ash::DisplayLayout::BOTTOM, 0));
781 783
782 { 784 {
783 window_->SetBounds(gfx::Rect(100, 200, 300, 20)); 785 window_->SetBounds(gfx::Rect(100, 200, 300, 20));
784 DCHECK_LT(window_->bounds().height(), 786 DCHECK_LT(window_->bounds().height(),
785 WorkspaceWindowResizer::kMinOnscreenHeight); 787 WorkspaceWindowResizer::kMinOnscreenHeight);
788 // Drag down avoiding dragging along the edge as that would side-snap.
786 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 789 scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
787 window_.get(), gfx::Point(), HTCAPTION)); 790 window_.get(), gfx::Point(10, 0), HTCAPTION));
788 ASSERT_TRUE(resizer.get()); 791 ASSERT_TRUE(resizer.get());
789 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); 792 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0);
790 int expected_y = kRootHeight - window_->bounds().height() - 10; 793 int expected_y = kRootHeight - window_->bounds().height() - 10;
791 // When the mouse cursor is in the primary display, the window cannot move 794 // When the mouse cursor is in the primary display, the window cannot move
792 // on non-work area but can get all the way towards the bottom, 795 // on non-work area but can get all the way towards the bottom,
793 // restricted only by the window height. 796 // restricted only by the window height.
794 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x20", 797 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x20",
795 window_->bounds().ToString()); 798 window_->bounds().ToString());
796 // Revert the drag in order to not remember the restore bounds. 799 // Revert the drag in order to not remember the restore bounds.
797 resizer->RevertDrag(); 800 resizer->RevertDrag();
798 } 801 }
799 802
800 Shell::GetInstance()->SetDisplayWorkAreaInsets( 803 Shell::GetInstance()->SetDisplayWorkAreaInsets(
801 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); 804 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0));
802 { 805 {
803 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); 806 window_->SetBounds(gfx::Rect(100, 200, 300, 400));
804 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 807 scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
805 window_.get(), gfx::Point(), HTCAPTION)); 808 window_.get(), gfx::Point(10, 0), HTCAPTION));
806 ASSERT_TRUE(resizer.get()); 809 ASSERT_TRUE(resizer.get());
810 // Drag down avoiding dragging along the edge as that would side-snap.
807 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); 811 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0);
808 int expected_y = 812 int expected_y =
809 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; 813 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10;
810 // When the mouse cursor is in the primary display, the window cannot move 814 // When the mouse cursor is in the primary display, the window cannot move
811 // on non-work area with kMinOnscreenHeight margin. 815 // on non-work area with kMinOnscreenHeight margin.
812 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", 816 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400",
813 window_->bounds().ToString()); 817 window_->bounds().ToString());
814 resizer->CompleteDrag(0); 818 resizer->CompleteDrag(0);
815 } 819 }
816 820
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 RunAnimationTillComplete(phantom_controller->animation_.get()); 2014 RunAnimationTillComplete(phantom_controller->animation_.get());
2011 2015
2012 // Hide phantom controller. Both widgets should close. 2016 // Hide phantom controller. Both widgets should close.
2013 phantom_controller->Hide(); 2017 phantom_controller->Hide();
2014 EXPECT_FALSE(phantom_controller->phantom_widget_); 2018 EXPECT_FALSE(phantom_controller->phantom_widget_);
2015 EXPECT_FALSE(phantom_controller->phantom_widget_start_); 2019 EXPECT_FALSE(phantom_controller->phantom_widget_start_);
2016 } 2020 }
2017 2021
2018 } // namespace internal 2022 } // namespace internal
2019 } // namespace ash 2023 } // namespace ash
OLDNEW
« ash/wm/workspace/workspace_window_resizer.cc ('K') | « ash/wm/workspace/workspace_window_resizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698