| 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/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/screen_ash.h" | 9 #include "ash/screen_ash.h" |
| 10 #include "ash/shelf/shelf_layout_manager.h" |
| 10 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 11 #include "ash/shell_window_ids.h" | 12 #include "ash/shell_window_ids.h" |
| 12 #include "ash/test/ash_test_base.h" | 13 #include "ash/test/ash_test_base.h" |
| 13 #include "ash/wm/property_util.h" | 14 #include "ash/wm/property_util.h" |
| 14 #include "ash/wm/shelf_layout_manager.h" | |
| 15 #include "ash/wm/window_util.h" | 15 #include "ash/wm/window_util.h" |
| 16 #include "ash/wm/workspace/phantom_window_controller.h" | 16 #include "ash/wm/workspace/phantom_window_controller.h" |
| 17 #include "ash/wm/workspace/snap_sizer.h" | 17 #include "ash/wm/workspace/snap_sizer.h" |
| 18 #include "ash/wm/workspace_controller.h" | 18 #include "ash/wm/workspace_controller.h" |
| 19 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
| 20 #include "base/stringprintf.h" | 20 #include "base/stringprintf.h" |
| 21 #include "ui/aura/client/aura_constants.h" | 21 #include "ui/aura/client/aura_constants.h" |
| 22 #include "ui/aura/root_window.h" | 22 #include "ui/aura/root_window.h" |
| 23 #include "ui/aura/test/test_window_delegate.h" | 23 #include "ui/aura/test/test_window_delegate.h" |
| 24 #include "ui/base/hit_test.h" | 24 #include "ui/base/hit_test.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 location.set_x(location.x() + delta_x); | 139 location.set_x(location.x() + delta_x); |
| 140 location.set_y(location.y() + delta_y); | 140 location.set_y(location.y() + delta_y); |
| 141 return location; | 141 return location; |
| 142 } | 142 } |
| 143 | 143 |
| 144 std::vector<aura::Window*> empty_windows() const { | 144 std::vector<aura::Window*> empty_windows() const { |
| 145 return std::vector<aura::Window*>(); | 145 return std::vector<aura::Window*>(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 internal::ShelfLayoutManager* shelf_layout_manager() { | 148 internal::ShelfLayoutManager* shelf_layout_manager() { |
| 149 return Shell::GetPrimaryRootWindowController()->shelf(); | 149 return Shell::GetPrimaryRootWindowController()->shelf_layout_manager(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 TestWindowDelegate delegate_; | 152 TestWindowDelegate delegate_; |
| 153 TestWindowDelegate delegate2_; | 153 TestWindowDelegate delegate2_; |
| 154 TestWindowDelegate delegate3_; | 154 TestWindowDelegate delegate3_; |
| 155 TestWindowDelegate delegate4_; | 155 TestWindowDelegate delegate4_; |
| 156 scoped_ptr<aura::Window> window_; | 156 scoped_ptr<aura::Window> window_; |
| 157 scoped_ptr<aura::Window> window2_; | 157 scoped_ptr<aura::Window> window2_; |
| 158 scoped_ptr<aura::Window> window3_; | 158 scoped_ptr<aura::Window> window3_; |
| 159 scoped_ptr<aura::Window> window4_; | 159 scoped_ptr<aura::Window> window4_; |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 795 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
| 796 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); | 796 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); |
| 797 EXPECT_EQ(base::IntToString(window_x + window_width) + | 797 EXPECT_EQ(base::IntToString(window_x + window_width) + |
| 798 ",100 " + | 798 ",100 " + |
| 799 base::IntToString(window_width) + | 799 base::IntToString(window_width) + |
| 800 "x380", window_->bounds().ToString()); | 800 "x380", window_->bounds().ToString()); |
| 801 } | 801 } |
| 802 | 802 |
| 803 // Verifies snapping to edges works. | 803 // Verifies snapping to edges works. |
| 804 TEST_F(WorkspaceWindowResizerTest, SnapToEdge) { | 804 TEST_F(WorkspaceWindowResizerTest, SnapToEdge) { |
| 805 Shell::GetPrimaryRootWindowController()-> | 805 Shell::GetPrimaryRootWindowController()->shelf_layout_manager()-> |
| 806 SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 806 SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 807 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); | 807 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); |
| 808 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 808 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
| 809 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | 809 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
| 810 ASSERT_TRUE(resizer.get()); | 810 ASSERT_TRUE(resizer.get()); |
| 811 // Move to an x-coordinate of 15, which should not snap. | 811 // Move to an x-coordinate of 15, which should not snap. |
| 812 resizer->Drag(CalculateDragPoint(*resizer, -81, 0), 0); | 812 resizer->Drag(CalculateDragPoint(*resizer, -81, 0), 0); |
| 813 // An x-coordinate of 7 should snap. | 813 // An x-coordinate of 7 should snap. |
| 814 resizer->Drag(CalculateDragPoint(*resizer, -89, 0), 0); | 814 resizer->Drag(CalculateDragPoint(*resizer, -89, 0), 0); |
| 815 EXPECT_EQ("0,112 320x160", window_->bounds().ToString()); | 815 EXPECT_EQ("0,112 320x160", window_->bounds().ToString()); |
| 816 // Move to -15, should still snap to 0. | 816 // Move to -15, should still snap to 0. |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1495 ASSERT_TRUE(resizer.get()); | 1495 ASSERT_TRUE(resizer.get()); |
| 1496 // Move it 50 to the left, which should contract w1 and expand w2-3. | 1496 // Move it 50 to the left, which should contract w1 and expand w2-3. |
| 1497 resizer->Drag(CalculateDragPoint(*resizer, -50, 0), 0); | 1497 resizer->Drag(CalculateDragPoint(*resizer, -50, 0), 0); |
| 1498 EXPECT_EQ("100,100 98x100", window_->bounds().ToString()); | 1498 EXPECT_EQ("100,100 98x100", window_->bounds().ToString()); |
| 1499 EXPECT_EQ("198,100 101x100", window2_->bounds().ToString()); | 1499 EXPECT_EQ("198,100 101x100", window2_->bounds().ToString()); |
| 1500 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); | 1500 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); |
| 1501 } | 1501 } |
| 1502 | 1502 |
| 1503 } // namespace internal | 1503 } // namespace internal |
| 1504 } // namespace ash | 1504 } // namespace ash |
| OLD | NEW |