Chromium Code Reviews| 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/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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 virtual gfx::Size GetMaximumSize() const OVERRIDE { | 91 virtual gfx::Size GetMaximumSize() const OVERRIDE { |
| 92 return max_size_; | 92 return max_size_; |
| 93 } | 93 } |
| 94 | 94 |
| 95 gfx::Size min_size_; | 95 gfx::Size min_size_; |
| 96 gfx::Size max_size_; | 96 gfx::Size max_size_; |
| 97 | 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(TestWindowDelegate); | 98 DISALLOW_COPY_AND_ASSIGN(TestWindowDelegate); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 }; // namespace | |
|
flackr
2013/11/07 03:06:05
nit: double space after } and no ;
i.e.
} // name
varkha
2013/11/07 03:23:20
Done.
| |
| 102 | |
| 101 class WorkspaceWindowResizerTest : public test::AshTestBase { | 103 class WorkspaceWindowResizerTest : public test::AshTestBase { |
| 102 public: | 104 public: |
| 103 WorkspaceWindowResizerTest() {} | 105 WorkspaceWindowResizerTest() : workspace_resizer_(NULL) {} |
| 104 virtual ~WorkspaceWindowResizerTest() {} | 106 virtual ~WorkspaceWindowResizerTest() {} |
| 105 | 107 |
| 106 virtual void SetUp() OVERRIDE { | 108 virtual void SetUp() OVERRIDE { |
| 107 AshTestBase::SetUp(); | 109 AshTestBase::SetUp(); |
| 108 UpdateDisplay(base::StringPrintf("800x%d", kRootHeight)); | 110 UpdateDisplay(base::StringPrintf("800x%d", kRootHeight)); |
| 109 | 111 |
| 110 aura::Window* root = Shell::GetPrimaryRootWindow(); | 112 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 111 gfx::Rect root_bounds(root->bounds()); | 113 gfx::Rect root_bounds(root->bounds()); |
| 112 #if defined(OS_WIN) | 114 #if defined(OS_WIN) |
| 113 // RootWindow and Display can't resize on Windows Ash. | 115 // RootWindow and Display can't resize on Windows Ash. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 if (*i == window_ || *i == window2_ || *i == window3_) { | 163 if (*i == window_ || *i == window2_ || *i == window3_) { |
| 162 if (!result.empty()) | 164 if (!result.empty()) |
| 163 result += " "; | 165 result += " "; |
| 164 result += base::IntToString((*i)->id()); | 166 result += base::IntToString((*i)->id()); |
| 165 } | 167 } |
| 166 } | 168 } |
| 167 return result; | 169 return result; |
| 168 } | 170 } |
| 169 | 171 |
| 170 protected: | 172 protected: |
| 171 gfx::Point CalculateDragPoint(const WorkspaceWindowResizer& resizer, | 173 WindowResizer* CreateResizerForTest( |
| 174 aura::Window* window, | |
| 175 const gfx::Point& point_in_parent, | |
| 176 int window_component) { | |
| 177 WindowResizer* resizer = CreateWindowResizer( | |
| 178 window, | |
| 179 point_in_parent, | |
| 180 window_component, | |
| 181 aura::client::WINDOW_MOVE_SOURCE_MOUSE).release(); | |
| 182 workspace_resizer_ = WorkspaceWindowResizer::instance_; | |
| 183 return resizer; | |
| 184 } | |
| 185 | |
| 186 PhantomWindowController* snap_phantom_window_controller() const { | |
| 187 return workspace_resizer_->snap_phantom_window_controller_.get(); | |
| 188 } | |
| 189 | |
| 190 gfx::Point CalculateDragPoint(const WindowResizer& resizer, | |
| 172 int delta_x, | 191 int delta_x, |
| 173 int delta_y) const { | 192 int delta_y) const { |
| 174 gfx::Point location = resizer.GetInitialLocation(); | 193 gfx::Point location = resizer.GetInitialLocation(); |
| 175 location.set_x(location.x() + delta_x); | 194 location.set_x(location.x() + delta_x); |
| 176 location.set_y(location.y() + delta_y); | 195 location.set_y(location.y() + delta_y); |
| 177 return location; | 196 return location; |
| 178 } | 197 } |
| 179 | 198 |
| 180 std::vector<aura::Window*> empty_windows() const { | 199 std::vector<aura::Window*> empty_windows() const { |
| 181 return std::vector<aura::Window*>(); | 200 return std::vector<aura::Window*>(); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 210 TestWindowDelegate delegate2_; | 229 TestWindowDelegate delegate2_; |
| 211 TestWindowDelegate delegate3_; | 230 TestWindowDelegate delegate3_; |
| 212 TestWindowDelegate delegate4_; | 231 TestWindowDelegate delegate4_; |
| 213 scoped_ptr<aura::Window> window_; | 232 scoped_ptr<aura::Window> window_; |
| 214 scoped_ptr<aura::Window> window2_; | 233 scoped_ptr<aura::Window> window2_; |
| 215 scoped_ptr<aura::Window> window3_; | 234 scoped_ptr<aura::Window> window3_; |
| 216 scoped_ptr<aura::Window> window4_; | 235 scoped_ptr<aura::Window> window4_; |
| 217 | 236 |
| 218 TestWindowDelegate touch_resize_delegate_; | 237 TestWindowDelegate touch_resize_delegate_; |
| 219 scoped_ptr<aura::Window> touch_resize_window_; | 238 scoped_ptr<aura::Window> touch_resize_window_; |
| 239 WorkspaceWindowResizer* workspace_resizer_; | |
| 220 | 240 |
| 221 private: | 241 private: |
| 222 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizerTest); | 242 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizerTest); |
| 223 }; | 243 }; |
| 224 | 244 |
| 225 class WorkspaceWindowResizerTestSticky : public WorkspaceWindowResizerTest { | 245 class WorkspaceWindowResizerTestSticky : public WorkspaceWindowResizerTest { |
| 226 public: | 246 public: |
| 227 WorkspaceWindowResizerTestSticky() {} | 247 WorkspaceWindowResizerTestSticky() {} |
| 228 virtual ~WorkspaceWindowResizerTestSticky() {} | 248 virtual ~WorkspaceWindowResizerTestSticky() {} |
| 229 | 249 |
| 230 virtual void SetUp() OVERRIDE { | 250 virtual void SetUp() OVERRIDE { |
| 231 CommandLine::ForCurrentProcess()->AppendSwitch( | 251 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 232 ash::switches::kAshEnableStickyEdges); | 252 ash::switches::kAshEnableStickyEdges); |
| 233 WorkspaceWindowResizerTest::SetUp(); | 253 WorkspaceWindowResizerTest::SetUp(); |
| 234 } | 254 } |
| 235 | 255 |
| 236 private: | 256 private: |
| 237 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizerTestSticky); | 257 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizerTestSticky); |
| 238 }; | 258 }; |
| 239 | 259 |
| 260 namespace { | |
| 261 | |
| 262 bool IsStickyEdgesEnabled() { | |
| 263 return (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 264 switches::kAshEnableStickyEdges)); | |
| 265 } | |
| 266 | |
| 240 } // namespace | 267 } // namespace |
| 241 | 268 |
| 242 // Assertions around attached window resize dragging from the right with 2 | 269 // Assertions around attached window resize dragging from the right with 2 |
| 243 // windows. | 270 // windows. |
| 244 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_2) { | 271 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_2) { |
| 245 window_->SetBounds(gfx::Rect(0, 300, 400, 300)); | 272 window_->SetBounds(gfx::Rect(0, 300, 400, 300)); |
| 246 window2_->SetBounds(gfx::Rect(400, 200, 100, 200)); | 273 window2_->SetBounds(gfx::Rect(400, 200, 100, 200)); |
| 247 | 274 |
| 248 std::vector<aura::Window*> windows; | 275 std::vector<aura::Window*> windows; |
| 249 windows.push_back(window2_.get()); | 276 windows.push_back(window2_.get()); |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 534 // 100 up again. | 561 // 100 up again. |
| 535 resizer->Drag(CalculateDragPoint(*resizer, -10, -100), 0); | 562 resizer->Drag(CalculateDragPoint(*resizer, -10, -100), 0); |
| 536 EXPECT_EQ("0,0 200x100", window_->bounds().ToString()); | 563 EXPECT_EQ("0,0 200x100", window_->bounds().ToString()); |
| 537 EXPECT_EQ("10,100 200x266", window2_->bounds().ToString()); | 564 EXPECT_EQ("10,100 200x266", window2_->bounds().ToString()); |
| 538 EXPECT_EQ("20,366 100x134", window3_->bounds().ToString()); | 565 EXPECT_EQ("20,366 100x134", window3_->bounds().ToString()); |
| 539 } | 566 } |
| 540 | 567 |
| 541 | 568 |
| 542 // Assertions around dragging to the left/right edge of the screen. | 569 // Assertions around dragging to the left/right edge of the screen. |
| 543 TEST_F(WorkspaceWindowResizerTest, Edge) { | 570 TEST_F(WorkspaceWindowResizerTest, Edge) { |
| 544 int bottom = | 571 // TODO(varkha): Insets are reset after every drag because of |
| 545 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); | 572 // http://crbug.com/292238. |
| 546 window_->SetBounds(gfx::Rect(20, 30, 50, 60)); | 573 // Window is wide enough not to get docked right away. |
| 574 window_->SetBounds(gfx::Rect(20, 30, 400, 60)); | |
| 547 wm::WindowState* window_state = wm::GetWindowState(window_.get()); | 575 wm::WindowState* window_state = wm::GetWindowState(window_.get()); |
| 548 | 576 |
| 549 { | 577 { |
| 550 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 578 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 551 window_.get(), gfx::Point(), HTCAPTION, | 579 window_.get(), gfx::Point(), HTCAPTION)); |
| 552 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 553 ASSERT_TRUE(resizer.get()); | 580 ASSERT_TRUE(resizer.get()); |
| 554 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0); | 581 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0); |
| 582 int bottom = | |
| 583 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); | |
| 555 resizer->CompleteDrag(0); | 584 resizer->CompleteDrag(0); |
| 556 EXPECT_EQ("0,0 720x" + base::IntToString(bottom), | 585 EXPECT_EQ("0,0 720x" + base::IntToString(bottom), |
| 557 window_->bounds().ToString()); | 586 window_->bounds().ToString()); |
| 558 ASSERT_TRUE(window_state->HasRestoreBounds()); | 587 ASSERT_TRUE(window_state->HasRestoreBounds()); |
| 559 EXPECT_EQ("20,30 50x60", | 588 EXPECT_EQ("20,30 400x60", |
| 560 window_state->GetRestoreBoundsInScreen().ToString()); | 589 window_state->GetRestoreBoundsInScreen().ToString()); |
| 561 } | 590 } |
| 562 // Try the same with the right side. | 591 // Try the same with the right side. |
| 563 { | 592 { |
| 564 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 593 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 565 window_.get(), gfx::Point(), HTCAPTION, | 594 window_.get(), gfx::Point(), HTCAPTION)); |
| 566 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 567 ASSERT_TRUE(resizer.get()); | 595 ASSERT_TRUE(resizer.get()); |
| 568 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); | 596 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); |
| 597 int bottom = | |
| 598 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); | |
| 569 resizer->CompleteDrag(0); | 599 resizer->CompleteDrag(0); |
| 570 EXPECT_EQ("80,0 720x" + base::IntToString(bottom), | 600 EXPECT_EQ("80,0 720x" + base::IntToString(bottom), |
| 571 window_->bounds().ToString()); | 601 window_->bounds().ToString()); |
| 572 ASSERT_TRUE(window_state->HasRestoreBounds()); | 602 ASSERT_TRUE(window_state->HasRestoreBounds()); |
| 573 EXPECT_EQ("20,30 50x60", | 603 EXPECT_EQ("20,30 400x60", |
| 574 window_state->GetRestoreBoundsInScreen().ToString()); | 604 window_state->GetRestoreBoundsInScreen().ToString()); |
| 575 } | 605 } |
| 576 | 606 |
| 577 // Test if the restore bounds is correct in multiple displays. | 607 // Test if the restore bounds is correct in multiple displays. |
| 578 window_state->ClearRestoreBounds(); | 608 window_state->ClearRestoreBounds(); |
| 579 | 609 |
| 580 if (!SupportsMultipleDisplays()) | 610 if (!SupportsMultipleDisplays()) |
| 581 return; | 611 return; |
| 582 | 612 |
| 583 UpdateDisplay("800x600,200x600"); | 613 UpdateDisplay("800x600,500x600"); |
| 584 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 614 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 585 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 615 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
| 586 window_->SetBoundsInScreen(gfx::Rect(800, 10, 50, 60), | 616 // Window is wide enough not to get docked right away. |
| 617 window_->SetBoundsInScreen(gfx::Rect(800, 10, 400, 60), | |
| 587 ScreenAsh::GetSecondaryDisplay()); | 618 ScreenAsh::GetSecondaryDisplay()); |
| 588 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | 619 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
| 589 { | 620 { |
| 590 bottom = | 621 EXPECT_EQ("800,10 400x60", window_->GetBoundsInScreen().ToString()); |
| 622 | |
| 623 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | |
| 624 window_.get(), gfx::Point(), HTCAPTION)); | |
| 625 ASSERT_TRUE(resizer.get()); | |
| 626 resizer->Drag(CalculateDragPoint(*resizer, 499, 00), 0); | |
| 627 int bottom = | |
| 591 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); | 628 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); |
| 592 EXPECT_EQ("800,10 50x60", window_->GetBoundsInScreen().ToString()); | |
| 593 | |
| 594 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | |
| 595 window_.get(), gfx::Point(), HTCAPTION, | |
| 596 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 597 ASSERT_TRUE(resizer.get()); | |
| 598 | |
| 599 resizer->Drag(CalculateDragPoint(*resizer, 199, 00), 0); | |
| 600 resizer->CompleteDrag(0); | 629 resizer->CompleteDrag(0); |
| 601 // With the resolution of 200x600 we will hit in this case the 50% screen | 630 // With the resolution of 500x600 we will hit in this case the 50% screen |
| 602 // size setting. | 631 // size setting. |
| 603 EXPECT_EQ("100,0 100x" + base::IntToString(bottom), | 632 // TODO(varkha): Insets are updated because of http://crbug.com/292238 |
| 633 EXPECT_EQ("250,0 250x" + base::IntToString(bottom), | |
| 604 window_->bounds().ToString()); | 634 window_->bounds().ToString()); |
| 605 EXPECT_EQ("800,10 50x60", | 635 EXPECT_EQ("800,10 400x60", |
| 606 window_state->GetRestoreBoundsInScreen().ToString()); | 636 window_state->GetRestoreBoundsInScreen().ToString()); |
| 607 } | 637 } |
| 608 } | 638 } |
| 609 | 639 |
| 610 // Check that non resizable windows will not get resized. | 640 // Check that non resizable windows will not get resized. |
| 611 TEST_F(WorkspaceWindowResizerTest, NonResizableWindows) { | 641 TEST_F(WorkspaceWindowResizerTest, NonResizableWindows) { |
| 612 window_->SetBounds(gfx::Rect(20, 30, 50, 60)); | 642 window_->SetBounds(gfx::Rect(20, 30, 50, 60)); |
| 613 window_->SetProperty(aura::client::kCanResizeKey, false); | 643 window_->SetProperty(aura::client::kCanResizeKey, false); |
| 614 | 644 |
| 615 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 645 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 616 window_.get(), gfx::Point(), HTCAPTION, | 646 window_.get(), gfx::Point(), HTCAPTION)); |
| 617 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 618 ASSERT_TRUE(resizer.get()); | 647 ASSERT_TRUE(resizer.get()); |
| 619 resizer->Drag(CalculateDragPoint(*resizer, -20, 0), 0); | 648 resizer->Drag(CalculateDragPoint(*resizer, -20, 0), 0); |
| 620 resizer->CompleteDrag(0); | 649 resizer->CompleteDrag(0); |
| 621 EXPECT_EQ("0,30 50x60", window_->bounds().ToString()); | 650 EXPECT_EQ("0,30 50x60", window_->bounds().ToString()); |
| 622 } | 651 } |
| 623 | 652 |
| 624 TEST_F(WorkspaceWindowResizerTest, CancelSnapPhantom) { | 653 TEST_F(WorkspaceWindowResizerTest, CancelSnapPhantom) { |
| 625 if (!SupportsMultipleDisplays()) | 654 if (!SupportsMultipleDisplays()) |
| 626 return; | 655 return; |
| 627 | 656 |
| 628 UpdateDisplay("800x600,800x600"); | 657 UpdateDisplay("800x600,800x600"); |
| 629 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 658 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 630 ASSERT_EQ(2U, root_windows.size()); | 659 ASSERT_EQ(2U, root_windows.size()); |
| 631 | 660 |
| 632 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), | 661 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), |
| 633 Shell::GetScreen()->GetPrimaryDisplay()); | 662 Shell::GetScreen()->GetPrimaryDisplay()); |
| 634 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 663 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
| 635 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); | 664 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); |
| 636 { | 665 { |
| 637 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 666 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 638 window_.get(), gfx::Point(), HTCAPTION, | 667 window_.get(), gfx::Point(), HTCAPTION)); |
| 639 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 640 ASSERT_TRUE(resizer.get()); | 668 ASSERT_TRUE(resizer.get()); |
| 641 EXPECT_FALSE(resizer->snap_phantom_window_controller_.get()); | 669 EXPECT_FALSE(snap_phantom_window_controller()); |
| 642 | 670 |
| 643 // The pointer is on the edge but not shared. The snap phantom window | 671 // The pointer is on the edge but not shared. The snap phantom window |
| 644 // controller should be non-NULL. | 672 // controller should be non-NULL. |
| 645 resizer->Drag(CalculateDragPoint(*resizer, 799, 0), 0); | 673 resizer->Drag(CalculateDragPoint(*resizer, 799, 0), 0); |
| 646 EXPECT_TRUE(resizer->snap_phantom_window_controller_.get()); | 674 EXPECT_TRUE(snap_phantom_window_controller()); |
| 647 | 675 |
| 648 // Move the cursor across the edge. Now the snap phantom window controller | 676 // Move the cursor across the edge. Now the snap phantom window controller |
| 649 // should be canceled. | 677 // should be canceled. |
| 650 resizer->Drag(CalculateDragPoint(*resizer, 800, 0), 0); | 678 resizer->Drag(CalculateDragPoint(*resizer, 800, 0), 0); |
| 651 EXPECT_FALSE(resizer->snap_phantom_window_controller_.get()); | 679 EXPECT_FALSE(snap_phantom_window_controller()); |
| 652 } | 680 } |
| 653 } | 681 } |
| 654 | 682 |
| 655 // Verifies windows are correctly restacked when reordering multiple windows. | 683 // Verifies windows are correctly restacked when reordering multiple windows. |
| 656 TEST_F(WorkspaceWindowResizerTest, RestackAttached) { | 684 TEST_F(WorkspaceWindowResizerTest, RestackAttached) { |
| 657 window_->SetBounds(gfx::Rect( 0, 0, 200, 300)); | 685 window_->SetBounds(gfx::Rect( 0, 0, 200, 300)); |
| 658 window2_->SetBounds(gfx::Rect(200, 0, 100, 200)); | 686 window2_->SetBounds(gfx::Rect(200, 0, 100, 200)); |
| 659 window3_->SetBounds(gfx::Rect(300, 0, 100, 100)); | 687 window3_->SetBounds(gfx::Rect(300, 0, 100, 100)); |
| 660 | 688 |
| 661 { | 689 { |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 688 } | 716 } |
| 689 | 717 |
| 690 // Makes sure we don't allow dragging below the work area. | 718 // Makes sure we don't allow dragging below the work area. |
| 691 TEST_F(WorkspaceWindowResizerTest, DontDragOffBottom) { | 719 TEST_F(WorkspaceWindowResizerTest, DontDragOffBottom) { |
| 692 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 720 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
| 693 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); | 721 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); |
| 694 | 722 |
| 695 ASSERT_EQ(1, Shell::GetScreen()->GetNumDisplays()); | 723 ASSERT_EQ(1, Shell::GetScreen()->GetNumDisplays()); |
| 696 | 724 |
| 697 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); | 725 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); |
| 698 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 726 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 699 window_.get(), gfx::Point(), HTCAPTION, | 727 window_.get(), gfx::Point(), HTCAPTION)); |
| 700 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 701 ASSERT_TRUE(resizer.get()); | 728 ASSERT_TRUE(resizer.get()); |
| 702 resizer->Drag(CalculateDragPoint(*resizer, 0, 600), 0); | 729 resizer->Drag(CalculateDragPoint(*resizer, 0, 600), 0); |
| 703 int expected_y = | 730 int expected_y = |
| 704 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; | 731 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; |
| 705 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", | 732 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", |
| 706 window_->bounds().ToString()); | 733 window_->bounds().ToString()); |
| 707 } | 734 } |
| 708 | 735 |
| 709 // Makes sure we don't allow dragging on the work area with multidisplay. | 736 // Makes sure we don't allow dragging on the work area with multidisplay. |
| 710 TEST_F(WorkspaceWindowResizerTest, DontDragOffBottomWithMultiDisplay) { | 737 TEST_F(WorkspaceWindowResizerTest, DontDragOffBottomWithMultiDisplay) { |
| 711 if (!SupportsMultipleDisplays()) | 738 if (!SupportsMultipleDisplays()) |
| 712 return; | 739 return; |
| 713 | 740 |
| 714 UpdateDisplay("800x600,800x600"); | 741 UpdateDisplay("800x600,800x600"); |
| 715 ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays()); | 742 ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays()); |
| 716 | 743 |
| 717 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 744 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
| 718 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); | 745 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); |
| 719 | 746 |
| 720 // Positions the secondary display at the bottom the primary display. | 747 // Positions the secondary display at the bottom the primary display. |
| 721 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( | 748 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
| 722 ash::DisplayLayout(ash::DisplayLayout::BOTTOM, 0)); | 749 ash::DisplayLayout(ash::DisplayLayout::BOTTOM, 0)); |
| 723 | 750 |
| 724 { | 751 { |
| 725 window_->SetBounds(gfx::Rect(100, 200, 300, 20)); | 752 window_->SetBounds(gfx::Rect(100, 200, 300, 20)); |
| 726 DCHECK_LT(window_->bounds().height(), | 753 DCHECK_LT(window_->bounds().height(), |
| 727 WorkspaceWindowResizer::kMinOnscreenHeight); | 754 WorkspaceWindowResizer::kMinOnscreenHeight); |
| 728 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 755 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 729 window_.get(), gfx::Point(), HTCAPTION, | 756 window_.get(), gfx::Point(), HTCAPTION)); |
| 730 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 731 ASSERT_TRUE(resizer.get()); | 757 ASSERT_TRUE(resizer.get()); |
| 732 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); | 758 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); |
| 733 int expected_y = kRootHeight - window_->bounds().height() - 10; | 759 int expected_y = kRootHeight - window_->bounds().height() - 10; |
| 734 // When the mouse cursor is in the primary display, the window cannot move | 760 // When the mouse cursor is in the primary display, the window cannot move |
| 735 // on non-work area but can get all the way towards the bottom, | 761 // on non-work area but can get all the way towards the bottom, |
| 736 // restricted only by the window height. | 762 // restricted only by the window height. |
| 737 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x20", | 763 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x20", |
| 738 window_->bounds().ToString()); | 764 window_->bounds().ToString()); |
| 765 // Revert the drag in order to not remember the restore bounds. | |
| 766 resizer->RevertDrag(); | |
| 739 } | 767 } |
| 740 | 768 |
| 769 Shell::GetInstance()->SetDisplayWorkAreaInsets( | |
| 770 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); | |
| 741 { | 771 { |
| 742 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); | 772 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); |
| 743 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 773 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 744 window_.get(), gfx::Point(), HTCAPTION, | 774 window_.get(), gfx::Point(), HTCAPTION)); |
| 745 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 746 ASSERT_TRUE(resizer.get()); | 775 ASSERT_TRUE(resizer.get()); |
| 747 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); | 776 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); |
| 748 int expected_y = | 777 int expected_y = |
| 749 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; | 778 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; |
| 750 // When the mouse cursor is in the primary display, the window cannot move | 779 // When the mouse cursor is in the primary display, the window cannot move |
| 751 // on non-work area with kMinOnscreenHeight margin. | 780 // on non-work area with kMinOnscreenHeight margin. |
| 752 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", | 781 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", |
| 753 window_->bounds().ToString()); | 782 window_->bounds().ToString()); |
| 783 resizer->CompleteDrag(0); | |
| 754 } | 784 } |
| 755 | 785 |
| 756 { | 786 { |
| 757 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); | 787 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); |
| 758 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 788 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 759 window_.get(), gfx::Point(), HTCAPTION, | 789 window_.get(), window_->bounds().origin(), HTCAPTION)); |
| 760 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 761 ASSERT_TRUE(resizer.get()); | 790 ASSERT_TRUE(resizer.get()); |
| 762 resizer->Drag(CalculateDragPoint(*resizer, 0, 600), 0); | 791 // Drag down avoiding getting stuck against the shelf on the bottom screen. |
| 792 resizer->Drag(CalculateDragPoint(*resizer, 0, 500), 0); | |
| 763 // The window can move to the secondary display beyond non-work area of | 793 // The window can move to the secondary display beyond non-work area of |
| 764 // the primary display. | 794 // the primary display. |
| 765 EXPECT_EQ("100,800 300x400", window_->bounds().ToString()); | 795 EXPECT_EQ("100,700 300x400", window_->bounds().ToString()); |
| 796 resizer->CompleteDrag(0); | |
| 766 } | 797 } |
| 767 } | 798 } |
| 768 | 799 |
| 769 // Makes sure we don't allow dragging off the top of the work area. | 800 // Makes sure we don't allow dragging off the top of the work area. |
| 770 TEST_F(WorkspaceWindowResizerTest, DontDragOffTop) { | 801 TEST_F(WorkspaceWindowResizerTest, DontDragOffTop) { |
| 771 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 802 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
| 772 Shell::GetPrimaryRootWindow(), gfx::Insets(10, 0, 0, 0)); | 803 Shell::GetPrimaryRootWindow(), gfx::Insets(10, 0, 0, 0)); |
| 773 | 804 |
| 774 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); | 805 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); |
| 775 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 806 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 776 window_.get(), gfx::Point(), HTCAPTION, | 807 window_.get(), gfx::Point(), HTCAPTION)); |
| 777 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 778 ASSERT_TRUE(resizer.get()); | 808 ASSERT_TRUE(resizer.get()); |
| 779 resizer->Drag(CalculateDragPoint(*resizer, 0, -600), 0); | 809 resizer->Drag(CalculateDragPoint(*resizer, 0, -600), 0); |
| 780 EXPECT_EQ("100,10 300x400", window_->bounds().ToString()); | 810 EXPECT_EQ("100,10 300x400", window_->bounds().ToString()); |
| 781 } | 811 } |
| 782 | 812 |
| 783 TEST_F(WorkspaceWindowResizerTest, ResizeBottomOutsideWorkArea) { | 813 TEST_F(WorkspaceWindowResizerTest, ResizeBottomOutsideWorkArea) { |
| 784 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 814 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
| 785 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 815 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); |
| 786 | 816 |
| 787 window_->SetBounds(gfx::Rect(100, 200, 300, 380)); | 817 window_->SetBounds(gfx::Rect(100, 200, 300, 380)); |
| 788 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 818 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 789 window_.get(), gfx::Point(), HTTOP, | 819 window_.get(), gfx::Point(), HTTOP)); |
| 790 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 791 ASSERT_TRUE(resizer.get()); | 820 ASSERT_TRUE(resizer.get()); |
| 792 resizer->Drag(CalculateDragPoint(*resizer, 8, 0), 0); | 821 resizer->Drag(CalculateDragPoint(*resizer, 8, 0), 0); |
| 793 EXPECT_EQ("100,200 300x380", window_->bounds().ToString()); | 822 EXPECT_EQ("100,200 300x380", window_->bounds().ToString()); |
| 794 } | 823 } |
| 795 | 824 |
| 796 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideLeftWorkArea) { | 825 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideLeftWorkArea) { |
| 797 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 826 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
| 798 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 827 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); |
| 799 int left = ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).x(); | 828 int left = ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).x(); |
| 800 int pixels_to_left_border = 50; | 829 int pixels_to_left_border = 50; |
| 801 int window_width = 300; | 830 int window_width = 300; |
| 802 int window_x = left - window_width + pixels_to_left_border; | 831 int window_x = left - window_width + pixels_to_left_border; |
| 803 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 832 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
| 804 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 833 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 805 window_.get(), gfx::Point(pixels_to_left_border, 0), HTRIGHT, | 834 window_.get(), gfx::Point(pixels_to_left_border, 0), HTRIGHT)); |
| 806 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 807 ASSERT_TRUE(resizer.get()); | 835 ASSERT_TRUE(resizer.get()); |
| 808 resizer->Drag(CalculateDragPoint(*resizer, -window_width, 0), 0); | 836 resizer->Drag(CalculateDragPoint(*resizer, -window_width, 0), 0); |
| 809 EXPECT_EQ(base::IntToString(window_x) + ",100 " + | 837 EXPECT_EQ(base::IntToString(window_x) + ",100 " + |
| 810 base::IntToString(kMinimumOnScreenArea - window_x) + | 838 base::IntToString(kMinimumOnScreenArea - window_x) + |
| 811 "x380", window_->bounds().ToString()); | 839 "x380", window_->bounds().ToString()); |
| 812 } | 840 } |
| 813 | 841 |
| 814 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideRightWorkArea) { | 842 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideRightWorkArea) { |
| 815 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 843 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
| 816 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 844 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); |
| 817 int right = ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 845 int right = ScreenAsh::GetDisplayWorkAreaBoundsInParent( |
| 818 window_.get()).right(); | 846 window_.get()).right(); |
| 819 int pixels_to_right_border = 50; | 847 int pixels_to_right_border = 50; |
| 820 int window_width = 300; | 848 int window_width = 300; |
| 821 int window_x = right - pixels_to_right_border; | 849 int window_x = right - pixels_to_right_border; |
| 822 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 850 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
| 823 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 851 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 824 window_.get(), gfx::Point(window_x, 0), HTLEFT, | 852 window_.get(), gfx::Point(window_x, 0), HTLEFT)); |
| 825 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 826 ASSERT_TRUE(resizer.get()); | 853 ASSERT_TRUE(resizer.get()); |
| 827 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); | 854 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); |
| 828 EXPECT_EQ(base::IntToString(right - kMinimumOnScreenArea) + | 855 EXPECT_EQ(base::IntToString(right - kMinimumOnScreenArea) + |
| 829 ",100 " + | 856 ",100 " + |
| 830 base::IntToString(window_width - pixels_to_right_border + | 857 base::IntToString(window_width - pixels_to_right_border + |
| 831 kMinimumOnScreenArea) + | 858 kMinimumOnScreenArea) + |
| 832 "x380", window_->bounds().ToString()); | 859 "x380", window_->bounds().ToString()); |
| 833 } | 860 } |
| 834 | 861 |
| 835 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideBottomWorkArea) { | 862 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideBottomWorkArea) { |
| 836 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 863 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
| 837 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 864 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); |
| 838 int bottom = ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 865 int bottom = ScreenAsh::GetDisplayWorkAreaBoundsInParent( |
| 839 window_.get()).bottom(); | 866 window_.get()).bottom(); |
| 840 int delta_to_bottom = 50; | 867 int delta_to_bottom = 50; |
| 841 int height = 380; | 868 int height = 380; |
| 842 window_->SetBounds(gfx::Rect(100, bottom - delta_to_bottom, 300, height)); | 869 window_->SetBounds(gfx::Rect(100, bottom - delta_to_bottom, 300, height)); |
| 843 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 870 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 844 window_.get(), gfx::Point(0, bottom - delta_to_bottom), HTTOP, | 871 window_.get(), gfx::Point(0, bottom - delta_to_bottom), HTTOP)); |
| 845 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 846 ASSERT_TRUE(resizer.get()); | 872 ASSERT_TRUE(resizer.get()); |
| 847 resizer->Drag(CalculateDragPoint(*resizer, 0, bottom), 0); | 873 resizer->Drag(CalculateDragPoint(*resizer, 0, bottom), 0); |
| 848 EXPECT_EQ("100," + | 874 EXPECT_EQ("100," + |
| 849 base::IntToString(bottom - kMinimumOnScreenArea) + | 875 base::IntToString(bottom - kMinimumOnScreenArea) + |
| 850 " 300x" + | 876 " 300x" + |
| 851 base::IntToString(height - (delta_to_bottom - | 877 base::IntToString(height - (delta_to_bottom - |
| 852 kMinimumOnScreenArea)), | 878 kMinimumOnScreenArea)), |
| 853 window_->bounds().ToString()); | 879 window_->bounds().ToString()); |
| 854 } | 880 } |
| 855 | 881 |
| 856 // Verifies that 'outside' check of the resizer take into account the extended | 882 // Verifies that 'outside' check of the resizer take into account the extended |
| 857 // desktop in case of repositions. | 883 // desktop in case of repositions. |
| 858 TEST_F(WorkspaceWindowResizerTest, DragWindowOutsideRightToSecondaryDisplay) { | 884 TEST_F(WorkspaceWindowResizerTest, DragWindowOutsideRightToSecondaryDisplay) { |
| 859 // Only primary display. Changes the window position to fit within the | 885 // Only primary display. Changes the window position to fit within the |
| 860 // display. | 886 // display. |
| 861 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 887 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
| 862 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 888 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); |
| 863 int right = ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 889 int right = ScreenAsh::GetDisplayWorkAreaBoundsInParent( |
| 864 window_.get()).right(); | 890 window_.get()).right(); |
| 865 int pixels_to_right_border = 50; | 891 int pixels_to_right_border = 50; |
| 866 int window_width = 300; | 892 int window_width = 300; |
| 867 int window_x = right - pixels_to_right_border; | 893 int window_x = right - pixels_to_right_border; |
| 868 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 894 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
| 869 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 895 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 870 window_.get(), gfx::Point(window_x, 0), HTCAPTION, | 896 window_.get(), gfx::Point(window_x, 0), HTCAPTION)); |
| 871 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 872 ASSERT_TRUE(resizer.get()); | 897 ASSERT_TRUE(resizer.get()); |
| 873 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); | 898 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); |
| 874 EXPECT_EQ(base::IntToString(right - kMinimumOnScreenArea) + | 899 EXPECT_EQ(base::IntToString(right - kMinimumOnScreenArea) + |
| 875 ",100 " + | 900 ",100 " + |
| 876 base::IntToString(window_width) + | 901 base::IntToString(window_width) + |
| 877 "x380", window_->bounds().ToString()); | 902 "x380", window_->bounds().ToString()); |
| 878 | 903 |
| 879 if (!SupportsMultipleDisplays()) | 904 if (!SupportsMultipleDisplays()) |
| 880 return; | 905 return; |
| 881 | 906 |
| 882 // With secondary display. Operation itself is same but doesn't change | 907 // With secondary display. Operation itself is same but doesn't change |
| 883 // the position because the window is still within the secondary display. | 908 // the position because the window is still within the secondary display. |
| 884 UpdateDisplay("1000x600,600x400"); | 909 UpdateDisplay("1000x600,600x400"); |
| 885 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 910 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
| 886 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 911 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); |
| 887 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 912 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
| 888 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); | 913 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); |
| 889 EXPECT_EQ(base::IntToString(window_x + window_width) + | 914 EXPECT_EQ(base::IntToString(window_x + window_width) + |
| 890 ",100 " + | 915 ",100 " + |
| 891 base::IntToString(window_width) + | 916 base::IntToString(window_width) + |
| 892 "x380", window_->bounds().ToString()); | 917 "x380", window_->bounds().ToString()); |
| 893 } | 918 } |
| 894 | 919 |
| 895 // Verifies snapping to edges works. | 920 // Verifies snapping to edges works. |
| 896 TEST_F(WorkspaceWindowResizerTest, SnapToEdge) { | 921 TEST_F(WorkspaceWindowResizerTest, SnapToEdge) { |
| 922 if (IsStickyEdgesEnabled()) | |
|
flackr
2013/11/07 03:06:05
If/when sticky edges is enabled by default, these
varkha
2013/11/07 03:23:20
Done.
| |
| 923 return; | |
| 897 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager()-> | 924 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager()-> |
| 898 SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 925 SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 899 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); | 926 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); |
| 900 // Click 50px to the right so that the mouse pointer does not leave the | 927 // Click 50px to the right so that the mouse pointer does not leave the |
| 901 // workspace ensuring sticky behavior. | 928 // workspace ensuring sticky behavior. |
| 902 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 929 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 903 window_.get(), | 930 window_.get(), |
| 904 window_->bounds().origin() + gfx::Vector2d(50, 0), | 931 window_->bounds().origin() + gfx::Vector2d(50, 0), |
| 905 HTCAPTION, | 932 HTCAPTION)); |
| 906 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 907 ASSERT_TRUE(resizer.get()); | 933 ASSERT_TRUE(resizer.get()); |
| 908 // Move to an x-coordinate of 15, which should not snap. | 934 // Move to an x-coordinate of 15, which should not snap. |
| 909 resizer->Drag(CalculateDragPoint(*resizer, 15 - 96, 0), 0); | 935 resizer->Drag(CalculateDragPoint(*resizer, 15 - 96, 0), 0); |
| 910 // An x-coordinate of 7 should snap. | 936 // An x-coordinate of 7 should snap. |
| 911 resizer->Drag(CalculateDragPoint(*resizer, 7 - 96, 0), 0); | 937 resizer->Drag(CalculateDragPoint(*resizer, 7 - 96, 0), 0); |
| 912 EXPECT_EQ("0,112 320x160", window_->bounds().ToString()); | 938 EXPECT_EQ("0,112 320x160", window_->bounds().ToString()); |
| 913 // Move to -15, should still snap to 0. | 939 // Move to -15, should still snap to 0. |
| 914 resizer->Drag(CalculateDragPoint(*resizer, -15 - 96, 0), 0); | 940 resizer->Drag(CalculateDragPoint(*resizer, -15 - 96, 0), 0); |
| 915 EXPECT_EQ("0,112 320x160", window_->bounds().ToString()); | 941 EXPECT_EQ("0,112 320x160", window_->bounds().ToString()); |
| 916 // At -32 should move past snap points. | 942 // At -32 should move past snap points. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 960 EXPECT_EQ("-32,470 320x160", window_->bounds().ToString()); | 986 EXPECT_EQ("-32,470 320x160", window_->bounds().ToString()); |
| 961 resizer->Drag( | 987 resizer->Drag( |
| 962 CalculateDragPoint(*resizer, -33 - 96, 600 - 160 - 112 - 2 + 33), 0); | 988 CalculateDragPoint(*resizer, -33 - 96, 600 - 160 - 112 - 2 + 33), 0); |
| 963 EXPECT_EQ("-33,471 320x160", window_->bounds().ToString()); | 989 EXPECT_EQ("-33,471 320x160", window_->bounds().ToString()); |
| 964 | 990 |
| 965 // No need to test dragging < 0 as we force that to 0. | 991 // No need to test dragging < 0 as we force that to 0. |
| 966 } | 992 } |
| 967 | 993 |
| 968 // Verifies a resize snap when dragging TOPLEFT. | 994 // Verifies a resize snap when dragging TOPLEFT. |
| 969 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_TOPLEFT) { | 995 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_TOPLEFT) { |
| 996 if (IsStickyEdgesEnabled()) | |
| 997 return; | |
| 970 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 998 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
| 971 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 999 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 972 window_.get(), gfx::Point(), HTTOPLEFT, | 1000 window_.get(), gfx::Point(), HTTOPLEFT)); |
| 973 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 974 ASSERT_TRUE(resizer.get()); | 1001 ASSERT_TRUE(resizer.get()); |
| 975 resizer->Drag(CalculateDragPoint(*resizer, -98, -199), 0); | 1002 resizer->Drag(CalculateDragPoint(*resizer, -98, -199), 0); |
| 976 EXPECT_EQ("0,0 120x230", window_->bounds().ToString()); | 1003 EXPECT_EQ("0,0 120x230", window_->bounds().ToString()); |
| 977 } | 1004 } |
| 978 | 1005 |
| 979 // Verifies a resize snap when dragging TOPRIGHT. | 1006 // Verifies a resize snap when dragging TOPRIGHT. |
| 980 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_TOPRIGHT) { | 1007 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_TOPRIGHT) { |
| 1008 if (IsStickyEdgesEnabled()) | |
| 1009 return; | |
| 981 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1010 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
| 982 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 1011 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( |
| 983 window_.get())); | 1012 window_.get())); |
| 984 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1013 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 985 window_.get(), gfx::Point(), HTTOPRIGHT, | 1014 window_.get(), gfx::Point(), HTTOPRIGHT)); |
| 986 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 987 ASSERT_TRUE(resizer.get()); | 1015 ASSERT_TRUE(resizer.get()); |
| 988 resizer->Drag( | 1016 resizer->Drag( |
| 989 CalculateDragPoint(*resizer, work_area.right() - 120 - 1, -199), 0); | 1017 CalculateDragPoint(*resizer, work_area.right() - 120 - 1, -199), 0); |
| 990 EXPECT_EQ(100, window_->bounds().x()); | 1018 EXPECT_EQ(100, window_->bounds().x()); |
| 991 EXPECT_EQ(work_area.y(), window_->bounds().y()); | 1019 EXPECT_EQ(work_area.y(), window_->bounds().y()); |
| 992 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); | 1020 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); |
| 993 EXPECT_EQ(230, window_->bounds().height()); | 1021 EXPECT_EQ(230, window_->bounds().height()); |
| 994 } | 1022 } |
| 995 | 1023 |
| 996 // Verifies a resize snap when dragging BOTTOMRIGHT. | 1024 // Verifies a resize snap when dragging BOTTOMRIGHT. |
| 997 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMRIGHT) { | 1025 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMRIGHT) { |
| 1026 if (IsStickyEdgesEnabled()) | |
| 1027 return; | |
| 998 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1028 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
| 999 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 1029 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( |
| 1000 window_.get())); | 1030 window_.get())); |
| 1001 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1031 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1002 window_.get(), gfx::Point(), HTBOTTOMRIGHT, | 1032 window_.get(), gfx::Point(), HTBOTTOMRIGHT)); |
| 1003 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1004 ASSERT_TRUE(resizer.get()); | 1033 ASSERT_TRUE(resizer.get()); |
| 1005 resizer->Drag( | 1034 resizer->Drag( |
| 1006 CalculateDragPoint(*resizer, work_area.right() - 120 - 1, | 1035 CalculateDragPoint(*resizer, work_area.right() - 120 - 1, |
| 1007 work_area.bottom() - 220 - 2), 0); | 1036 work_area.bottom() - 220 - 2), 0); |
| 1008 EXPECT_EQ(100, window_->bounds().x()); | 1037 EXPECT_EQ(100, window_->bounds().x()); |
| 1009 EXPECT_EQ(200, window_->bounds().y()); | 1038 EXPECT_EQ(200, window_->bounds().y()); |
| 1010 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); | 1039 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); |
| 1011 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); | 1040 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); |
| 1012 } | 1041 } |
| 1013 | 1042 |
| 1014 // Verifies a resize snap when dragging BOTTOMLEFT. | 1043 // Verifies a resize snap when dragging BOTTOMLEFT. |
| 1015 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMLEFT) { | 1044 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMLEFT) { |
| 1045 if (IsStickyEdgesEnabled()) | |
| 1046 return; | |
| 1016 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1047 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
| 1017 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 1048 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( |
| 1018 window_.get())); | 1049 window_.get())); |
| 1019 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1050 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1020 window_.get(), gfx::Point(), HTBOTTOMLEFT, | 1051 window_.get(), gfx::Point(), HTBOTTOMLEFT)); |
| 1021 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1022 ASSERT_TRUE(resizer.get()); | 1052 ASSERT_TRUE(resizer.get()); |
| 1023 resizer->Drag( | 1053 resizer->Drag( |
| 1024 CalculateDragPoint(*resizer, -98, work_area.bottom() - 220 - 2), 0); | 1054 CalculateDragPoint(*resizer, -98, work_area.bottom() - 220 - 2), 0); |
| 1025 EXPECT_EQ(0, window_->bounds().x()); | 1055 EXPECT_EQ(0, window_->bounds().x()); |
| 1026 EXPECT_EQ(200, window_->bounds().y()); | 1056 EXPECT_EQ(200, window_->bounds().y()); |
| 1027 EXPECT_EQ(120, window_->bounds().width()); | 1057 EXPECT_EQ(120, window_->bounds().width()); |
| 1028 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); | 1058 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); |
| 1029 } | 1059 } |
| 1030 | 1060 |
| 1031 // Verifies sticking to edges works. | 1061 // Verifies sticking to edges works. |
| 1032 TEST_F(WorkspaceWindowResizerTestSticky, StickToEdge) { | 1062 TEST_F(WorkspaceWindowResizerTestSticky, StickToEdge) { |
| 1033 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager()-> | 1063 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager()-> |
| 1034 SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1064 SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1035 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); | 1065 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); |
| 1036 // Click 50px to the right so that the mouse pointer does not leave the | 1066 // Click 50px to the right so that the mouse pointer does not leave the |
| 1037 // workspace ensuring sticky behavior. | 1067 // workspace ensuring sticky behavior. |
| 1038 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1068 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1039 window_.get(), | 1069 window_.get(), |
| 1040 window_->bounds().origin() + gfx::Vector2d(50, 0), | 1070 window_->bounds().origin() + gfx::Vector2d(50, 0), |
| 1041 HTCAPTION, | 1071 HTCAPTION)); |
| 1042 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1043 ASSERT_TRUE(resizer.get()); | 1072 ASSERT_TRUE(resizer.get()); |
| 1044 // Move to an x-coordinate of 15, which should not stick. | 1073 // Move to an x-coordinate of 15, which should not stick. |
| 1045 resizer->Drag(CalculateDragPoint(*resizer, 15 - 96, 0), 0); | 1074 resizer->Drag(CalculateDragPoint(*resizer, 15 - 96, 0), 0); |
| 1046 // Move to -15, should still stick to 0. | 1075 // Move to -15, should still stick to 0. |
| 1047 resizer->Drag(CalculateDragPoint(*resizer, -15 - 96, 0), 0); | 1076 resizer->Drag(CalculateDragPoint(*resizer, -15 - 96, 0), 0); |
| 1048 EXPECT_EQ("0,112 320x160", window_->bounds().ToString()); | 1077 EXPECT_EQ("0,112 320x160", window_->bounds().ToString()); |
| 1049 // At -100 should move past edge. | 1078 // At -100 should move past edge. |
| 1050 resizer->Drag(CalculateDragPoint(*resizer, -100 - 96, 0), 0); | 1079 resizer->Drag(CalculateDragPoint(*resizer, -100 - 96, 0), 0); |
| 1051 EXPECT_EQ("-100,112 320x160", window_->bounds().ToString()); | 1080 EXPECT_EQ("-100,112 320x160", window_->bounds().ToString()); |
| 1052 resizer->Drag(CalculateDragPoint(*resizer, -101 - 96, 0), 0); | 1081 resizer->Drag(CalculateDragPoint(*resizer, -101 - 96, 0), 0); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1071 EXPECT_EQ("96,539 320x160", window_->bounds().ToString()); | 1100 EXPECT_EQ("96,539 320x160", window_->bounds().ToString()); |
| 1072 | 1101 |
| 1073 // No need to test dragging < 0 as we force that to 0. | 1102 // No need to test dragging < 0 as we force that to 0. |
| 1074 } | 1103 } |
| 1075 | 1104 |
| 1076 // Verifies not sticking to edges when a mouse pointer is outside of work area. | 1105 // Verifies not sticking to edges when a mouse pointer is outside of work area. |
| 1077 TEST_F(WorkspaceWindowResizerTestSticky, NoStickToEdgeWhenOutside) { | 1106 TEST_F(WorkspaceWindowResizerTestSticky, NoStickToEdgeWhenOutside) { |
| 1078 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager()-> | 1107 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager()-> |
| 1079 SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1108 SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1080 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); | 1109 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); |
| 1081 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1110 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1082 window_.get(), gfx::Point(), HTCAPTION, | 1111 window_.get(), gfx::Point(), HTCAPTION)); |
| 1083 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1084 ASSERT_TRUE(resizer.get()); | 1112 ASSERT_TRUE(resizer.get()); |
| 1085 // Move to an x-coordinate of 15, which should not stick. | 1113 // Move to an x-coordinate of 15, which should not stick. |
| 1086 resizer->Drag(CalculateDragPoint(*resizer, 15 - 96, 0), 0); | 1114 resizer->Drag(CalculateDragPoint(*resizer, 15 - 96, 0), 0); |
| 1087 // Move to -15, should still stick to 0. | 1115 // Move to -15, should still stick to 0. |
| 1088 resizer->Drag(CalculateDragPoint(*resizer, -15 - 96, 0), 0); | 1116 resizer->Drag(CalculateDragPoint(*resizer, -15 - 96, 0), 0); |
| 1089 EXPECT_EQ("-15,112 320x160", window_->bounds().ToString()); | 1117 EXPECT_EQ("-15,112 320x160", window_->bounds().ToString()); |
| 1090 } | 1118 } |
| 1091 | 1119 |
| 1092 // Verifies a resize sticks when dragging TOPLEFT. | 1120 // Verifies a resize sticks when dragging TOPLEFT. |
| 1093 TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_TOPLEFT) { | 1121 TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_TOPLEFT) { |
| 1094 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1122 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
| 1095 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1123 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1096 window_.get(), gfx::Point(), HTTOPLEFT, | 1124 window_.get(), gfx::Point(), HTTOPLEFT)); |
| 1097 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1098 ASSERT_TRUE(resizer.get()); | 1125 ASSERT_TRUE(resizer.get()); |
| 1099 resizer->Drag(CalculateDragPoint(*resizer, -15 - 100, -15 -200), 0); | 1126 resizer->Drag(CalculateDragPoint(*resizer, -15 - 100, -15 -200), 0); |
| 1100 EXPECT_EQ("0,0 120x230", window_->bounds().ToString()); | 1127 EXPECT_EQ("0,0 120x230", window_->bounds().ToString()); |
| 1101 } | 1128 } |
| 1102 | 1129 |
| 1103 // Verifies a resize sticks when dragging TOPRIGHT. | 1130 // Verifies a resize sticks when dragging TOPRIGHT. |
| 1104 TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_TOPRIGHT) { | 1131 TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_TOPRIGHT) { |
| 1105 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1132 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
| 1106 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 1133 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( |
| 1107 window_.get())); | 1134 window_.get())); |
| 1108 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1135 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1109 window_.get(), gfx::Point(), HTTOPRIGHT, | 1136 window_.get(), gfx::Point(), HTTOPRIGHT)); |
| 1110 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1111 ASSERT_TRUE(resizer.get()); | 1137 ASSERT_TRUE(resizer.get()); |
| 1112 resizer->Drag(CalculateDragPoint(*resizer, work_area.right() - 100 + 20, | 1138 resizer->Drag(CalculateDragPoint(*resizer, work_area.right() - 100 + 20, |
| 1113 -200 - 15), 0); | 1139 -200 - 15), 0); |
| 1114 EXPECT_EQ(100, window_->bounds().x()); | 1140 EXPECT_EQ(100, window_->bounds().x()); |
| 1115 EXPECT_EQ(work_area.y(), window_->bounds().y()); | 1141 EXPECT_EQ(work_area.y(), window_->bounds().y()); |
| 1116 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); | 1142 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); |
| 1117 EXPECT_EQ(230, window_->bounds().height()); | 1143 EXPECT_EQ(230, window_->bounds().height()); |
| 1118 } | 1144 } |
| 1119 | 1145 |
| 1120 // Verifies a resize snap when dragging BOTTOMRIGHT. | 1146 // Verifies a resize snap when dragging BOTTOMRIGHT. |
| 1121 TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_BOTTOMRIGHT) { | 1147 TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_BOTTOMRIGHT) { |
| 1122 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1148 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
| 1123 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 1149 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( |
| 1124 window_.get())); | 1150 window_.get())); |
| 1125 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1151 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1126 window_.get(), gfx::Point(), HTBOTTOMRIGHT, | 1152 window_.get(), gfx::Point(), HTBOTTOMRIGHT)); |
| 1127 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1128 ASSERT_TRUE(resizer.get()); | 1153 ASSERT_TRUE(resizer.get()); |
| 1129 resizer->Drag(CalculateDragPoint(*resizer, work_area.right() - 100 - 20 + 15, | 1154 resizer->Drag(CalculateDragPoint(*resizer, work_area.right() - 100 - 20 + 15, |
| 1130 work_area.bottom() - 200 - 30 + 15), 0); | 1155 work_area.bottom() - 200 - 30 + 15), 0); |
| 1131 EXPECT_EQ(100, window_->bounds().x()); | 1156 EXPECT_EQ(100, window_->bounds().x()); |
| 1132 EXPECT_EQ(200, window_->bounds().y()); | 1157 EXPECT_EQ(200, window_->bounds().y()); |
| 1133 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); | 1158 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); |
| 1134 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); | 1159 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); |
| 1135 } | 1160 } |
| 1136 | 1161 |
| 1137 // Verifies a resize snap when dragging BOTTOMLEFT. | 1162 // Verifies a resize snap when dragging BOTTOMLEFT. |
| 1138 TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_BOTTOMLEFT) { | 1163 TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_BOTTOMLEFT) { |
| 1139 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1164 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
| 1140 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 1165 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( |
| 1141 window_.get())); | 1166 window_.get())); |
| 1142 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1167 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1143 window_.get(), gfx::Point(), HTBOTTOMLEFT, | 1168 window_.get(), gfx::Point(), HTBOTTOMLEFT)); |
| 1144 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1145 ASSERT_TRUE(resizer.get()); | 1169 ASSERT_TRUE(resizer.get()); |
| 1146 resizer->Drag(CalculateDragPoint(*resizer, -15 - 100, | 1170 resizer->Drag(CalculateDragPoint(*resizer, -15 - 100, |
| 1147 work_area.bottom() - 200 - 30 + 15), 0); | 1171 work_area.bottom() - 200 - 30 + 15), 0); |
| 1148 EXPECT_EQ(0, window_->bounds().x()); | 1172 EXPECT_EQ(0, window_->bounds().x()); |
| 1149 EXPECT_EQ(200, window_->bounds().y()); | 1173 EXPECT_EQ(200, window_->bounds().y()); |
| 1150 EXPECT_EQ(120, window_->bounds().width()); | 1174 EXPECT_EQ(120, window_->bounds().width()); |
| 1151 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); | 1175 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); |
| 1152 } | 1176 } |
| 1153 | 1177 |
| 1154 TEST_F(WorkspaceWindowResizerTest, CtrlDragResizeToExactPosition) { | 1178 TEST_F(WorkspaceWindowResizerTest, CtrlDragResizeToExactPosition) { |
| 1155 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); | 1179 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); |
| 1156 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1180 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1157 window_.get(), gfx::Point(), HTBOTTOMRIGHT, | 1181 window_.get(), gfx::Point(), HTBOTTOMRIGHT)); |
| 1158 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1159 ASSERT_TRUE(resizer.get()); | 1182 ASSERT_TRUE(resizer.get()); |
| 1160 // Resize the right bottom to add 10 in width, 12 in height. | 1183 // Resize the right bottom to add 10 in width, 12 in height. |
| 1161 resizer->Drag(CalculateDragPoint(*resizer, 10, 12), ui::EF_CONTROL_DOWN); | 1184 resizer->Drag(CalculateDragPoint(*resizer, 10, 12), ui::EF_CONTROL_DOWN); |
| 1162 // Both bottom and right sides to resize to exact size requested. | 1185 // Both bottom and right sides to resize to exact size requested. |
| 1163 EXPECT_EQ("96,112 330x172", window_->bounds().ToString()); | 1186 EXPECT_EQ("96,112 330x172", window_->bounds().ToString()); |
| 1164 } | 1187 } |
| 1165 | 1188 |
| 1166 TEST_F(WorkspaceWindowResizerTest, CtrlCompleteDragMoveToExactPosition) { | 1189 TEST_F(WorkspaceWindowResizerTest, CtrlCompleteDragMoveToExactPosition) { |
| 1167 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); | 1190 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); |
| 1168 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1191 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1169 window_.get(), gfx::Point(), HTCAPTION, | 1192 window_.get(), gfx::Point(), HTCAPTION)); |
| 1170 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1171 ASSERT_TRUE(resizer.get()); | 1193 ASSERT_TRUE(resizer.get()); |
| 1172 // Ctrl + drag the window to new poistion by adding (10, 12) to its origin, | 1194 // Ctrl + drag the window to new poistion by adding (10, 12) to its origin, |
| 1173 // the window should move to the exact position. | 1195 // the window should move to the exact position. |
| 1174 resizer->Drag(CalculateDragPoint(*resizer, 10, 12), 0); | 1196 resizer->Drag(CalculateDragPoint(*resizer, 10, 12), 0); |
| 1175 resizer->CompleteDrag(ui::EF_CONTROL_DOWN); | 1197 resizer->CompleteDrag(ui::EF_CONTROL_DOWN); |
| 1176 EXPECT_EQ("106,124 320x160", window_->bounds().ToString()); | 1198 EXPECT_EQ("106,124 320x160", window_->bounds().ToString()); |
| 1177 } | 1199 } |
| 1178 | 1200 |
| 1179 // Verifies that a dragged window will restore to its pre-maximized size. | 1201 // Verifies that a dragged window will restore to its pre-maximized size. |
| 1180 TEST_F(WorkspaceWindowResizerTest, RestoreToPreMaximizeCoordinates) { | 1202 TEST_F(WorkspaceWindowResizerTest, RestoreToPreMaximizeCoordinates) { |
| 1181 window_->SetBounds(gfx::Rect(0, 0, 1000, 1000)); | 1203 window_->SetBounds(gfx::Rect(0, 0, 1000, 1000)); |
| 1182 wm::WindowState* window_state = wm::GetWindowState(window_.get()); | 1204 wm::WindowState* window_state = wm::GetWindowState(window_.get()); |
| 1183 window_state->SetRestoreBoundsInScreen(gfx::Rect(96, 112, 320, 160)); | 1205 window_state->SetRestoreBoundsInScreen(gfx::Rect(96, 112, 320, 160)); |
| 1184 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1206 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1185 window_.get(), gfx::Point(), HTCAPTION, | 1207 window_.get(), gfx::Point(), HTCAPTION)); |
| 1186 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1187 ASSERT_TRUE(resizer.get()); | 1208 ASSERT_TRUE(resizer.get()); |
| 1188 // Drag the window to new position by adding (10, 10) to original point, | 1209 // Drag the window to new position by adding (10, 10) to original point, |
| 1189 // the window should get restored. | 1210 // the window should get restored. |
| 1190 resizer->Drag(CalculateDragPoint(*resizer, 10, 10), 0); | 1211 resizer->Drag(CalculateDragPoint(*resizer, 10, 10), 0); |
| 1191 resizer->CompleteDrag(0); | 1212 resizer->CompleteDrag(0); |
| 1192 EXPECT_EQ("10,10 320x160", window_->bounds().ToString()); | 1213 EXPECT_EQ("10,10 320x160", window_->bounds().ToString()); |
| 1193 // The restore rectangle should get cleared as well. | 1214 // The restore rectangle should get cleared as well. |
| 1194 EXPECT_FALSE(window_state->HasRestoreBounds()); | 1215 EXPECT_FALSE(window_state->HasRestoreBounds()); |
| 1195 } | 1216 } |
| 1196 | 1217 |
| 1197 // Verifies that a dragged window will restore to its pre-maximized size. | 1218 // Verifies that a dragged window will restore to its pre-maximized size. |
| 1198 TEST_F(WorkspaceWindowResizerTest, RevertResizeOperation) { | 1219 TEST_F(WorkspaceWindowResizerTest, RevertResizeOperation) { |
| 1199 const gfx::Rect initial_bounds(0, 0, 200, 400); | 1220 const gfx::Rect initial_bounds(0, 0, 200, 400); |
| 1200 window_->SetBounds(initial_bounds); | 1221 window_->SetBounds(initial_bounds); |
| 1201 | 1222 |
| 1202 wm::WindowState* window_state = wm::GetWindowState(window_.get()); | 1223 wm::WindowState* window_state = wm::GetWindowState(window_.get()); |
| 1203 window_state->SetRestoreBoundsInScreen(gfx::Rect(96, 112, 320, 160)); | 1224 window_state->SetRestoreBoundsInScreen(gfx::Rect(96, 112, 320, 160)); |
| 1204 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1225 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1205 window_.get(), gfx::Point(), HTCAPTION, | 1226 window_.get(), gfx::Point(), HTCAPTION)); |
| 1206 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1207 ASSERT_TRUE(resizer.get()); | 1227 ASSERT_TRUE(resizer.get()); |
| 1208 // Drag the window to new poistion by adding (180, 16) to original point, | 1228 // Drag the window to new poistion by adding (180, 16) to original point, |
| 1209 // the window should get restored. | 1229 // the window should get restored. |
| 1210 resizer->Drag(CalculateDragPoint(*resizer, 180, 16), 0); | 1230 resizer->Drag(CalculateDragPoint(*resizer, 180, 16), 0); |
| 1211 resizer->RevertDrag(); | 1231 resizer->RevertDrag(); |
| 1212 EXPECT_EQ(initial_bounds.ToString(), window_->bounds().ToString()); | 1232 EXPECT_EQ(initial_bounds.ToString(), window_->bounds().ToString()); |
| 1213 EXPECT_EQ("96,112 320x160", | 1233 EXPECT_EQ("96,112 320x160", |
| 1214 window_state->GetRestoreBoundsInScreen().ToString()); | 1234 window_state->GetRestoreBoundsInScreen().ToString()); |
| 1215 } | 1235 } |
| 1216 | 1236 |
| 1217 // Check that only usable sizes get returned by the resizer. | 1237 // Check that only usable sizes get returned by the resizer. |
| 1218 TEST_F(WorkspaceWindowResizerTest, MagneticallyAttach) { | 1238 TEST_F(WorkspaceWindowResizerTest, MagneticallyAttach) { |
| 1219 window_->SetBounds(gfx::Rect(10, 10, 20, 30)); | 1239 window_->SetBounds(gfx::Rect(10, 10, 20, 30)); |
| 1220 window2_->SetBounds(gfx::Rect(150, 160, 25, 20)); | 1240 window2_->SetBounds(gfx::Rect(150, 160, 25, 20)); |
| 1221 window2_->Show(); | 1241 window2_->Show(); |
| 1222 | 1242 |
| 1223 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1243 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1224 window_.get(), gfx::Point(), HTCAPTION, | 1244 window_.get(), gfx::Point(), HTCAPTION)); |
| 1225 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1226 ASSERT_TRUE(resizer.get()); | 1245 ASSERT_TRUE(resizer.get()); |
| 1227 // Move |window| one pixel to the left of |window2|. Should snap to right and | 1246 // Move |window| one pixel to the left of |window2|. Should snap to right and |
| 1228 // top. | 1247 // top. |
| 1229 resizer->Drag(CalculateDragPoint(*resizer, 119, 145), 0); | 1248 resizer->Drag(CalculateDragPoint(*resizer, 119, 145), 0); |
| 1230 EXPECT_EQ("130,160 20x30", window_->bounds().ToString()); | 1249 EXPECT_EQ("130,160 20x30", window_->bounds().ToString()); |
| 1231 | 1250 |
| 1232 // Move |window| one pixel to the right of |window2|. Should snap to left and | 1251 // Move |window| one pixel to the right of |window2|. Should snap to left and |
| 1233 // top. | 1252 // top. |
| 1234 resizer->Drag(CalculateDragPoint(*resizer, 164, 145), 0); | 1253 resizer->Drag(CalculateDragPoint(*resizer, 164, 145), 0); |
| 1235 EXPECT_EQ("175,160 20x30", window_->bounds().ToString()); | 1254 EXPECT_EQ("175,160 20x30", window_->bounds().ToString()); |
| 1236 | 1255 |
| 1237 // Move |window| one pixel above |window2|. Should snap to top and left. | 1256 // Move |window| one pixel above |window2|. Should snap to top and left. |
| 1238 resizer->Drag(CalculateDragPoint(*resizer, 142, 119), 0); | 1257 resizer->Drag(CalculateDragPoint(*resizer, 142, 119), 0); |
| 1239 EXPECT_EQ("150,130 20x30", window_->bounds().ToString()); | 1258 EXPECT_EQ("150,130 20x30", window_->bounds().ToString()); |
| 1240 | 1259 |
| 1241 // Move |window| one pixel above the bottom of |window2|. Should snap to | 1260 // Move |window| one pixel above the bottom of |window2|. Should snap to |
| 1242 // bottom and left. | 1261 // bottom and left. |
| 1243 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0); | 1262 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0); |
| 1244 EXPECT_EQ("150,180 20x30", window_->bounds().ToString()); | 1263 EXPECT_EQ("150,180 20x30", window_->bounds().ToString()); |
| 1245 } | 1264 } |
| 1246 | 1265 |
| 1247 // The following variants verify magnetic snapping during resize when dragging a | 1266 // The following variants verify magnetic snapping during resize when dragging a |
| 1248 // particular edge. | 1267 // particular edge. |
| 1249 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_TOP) { | 1268 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_TOP) { |
| 1250 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1269 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
| 1251 window2_->SetBounds(gfx::Rect(99, 179, 10, 20)); | 1270 window2_->SetBounds(gfx::Rect(99, 179, 10, 20)); |
| 1252 window2_->Show(); | 1271 window2_->Show(); |
| 1253 | 1272 |
| 1254 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1273 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1255 window_.get(), gfx::Point(), HTTOP, | 1274 window_.get(), gfx::Point(), HTTOP)); |
| 1256 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1257 ASSERT_TRUE(resizer.get()); | 1275 ASSERT_TRUE(resizer.get()); |
| 1258 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1276 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
| 1259 EXPECT_EQ("100,199 20x31", window_->bounds().ToString()); | 1277 EXPECT_EQ("100,199 20x31", window_->bounds().ToString()); |
| 1260 } | 1278 } |
| 1261 | 1279 |
| 1262 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_TOPLEFT) { | 1280 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_TOPLEFT) { |
| 1263 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1281 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
| 1264 window2_->SetBounds(gfx::Rect(99, 179, 10, 20)); | 1282 window2_->SetBounds(gfx::Rect(99, 179, 10, 20)); |
| 1265 window2_->Show(); | 1283 window2_->Show(); |
| 1266 | 1284 |
| 1267 { | 1285 { |
| 1268 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1286 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1269 window_.get(), gfx::Point(), HTTOPLEFT, | 1287 window_.get(), gfx::Point(), HTTOPLEFT)); |
| 1270 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1271 ASSERT_TRUE(resizer.get()); | 1288 ASSERT_TRUE(resizer.get()); |
| 1272 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1289 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
| 1273 EXPECT_EQ("99,199 21x31", window_->bounds().ToString()); | 1290 EXPECT_EQ("99,199 21x31", window_->bounds().ToString()); |
| 1274 resizer->RevertDrag(); | 1291 resizer->RevertDrag(); |
| 1275 } | 1292 } |
| 1276 | 1293 |
| 1277 { | 1294 { |
| 1278 window2_->SetBounds(gfx::Rect(88, 201, 10, 20)); | 1295 window2_->SetBounds(gfx::Rect(88, 201, 10, 20)); |
| 1279 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1296 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1280 window_.get(), gfx::Point(), HTTOPLEFT, | 1297 window_.get(), gfx::Point(), HTTOPLEFT)); |
| 1281 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1282 ASSERT_TRUE(resizer.get()); | 1298 ASSERT_TRUE(resizer.get()); |
| 1283 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1299 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
| 1284 EXPECT_EQ("98,201 22x29", window_->bounds().ToString()); | 1300 EXPECT_EQ("98,201 22x29", window_->bounds().ToString()); |
| 1285 resizer->RevertDrag(); | 1301 resizer->RevertDrag(); |
| 1286 } | 1302 } |
| 1287 } | 1303 } |
| 1288 | 1304 |
| 1289 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_TOPRIGHT) { | 1305 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_TOPRIGHT) { |
| 1290 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1306 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
| 1291 window2_->Show(); | 1307 window2_->Show(); |
| 1292 | 1308 |
| 1293 { | 1309 { |
| 1294 window2_->SetBounds(gfx::Rect(111, 179, 10, 20)); | 1310 window2_->SetBounds(gfx::Rect(111, 179, 10, 20)); |
| 1295 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1311 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1296 window_.get(), gfx::Point(), HTTOPRIGHT, | 1312 window_.get(), gfx::Point(), HTTOPRIGHT)); |
| 1297 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1298 ASSERT_TRUE(resizer.get()); | 1313 ASSERT_TRUE(resizer.get()); |
| 1299 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1314 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
| 1300 EXPECT_EQ("100,199 21x31", window_->bounds().ToString()); | 1315 EXPECT_EQ("100,199 21x31", window_->bounds().ToString()); |
| 1301 resizer->RevertDrag(); | 1316 resizer->RevertDrag(); |
| 1302 } | 1317 } |
| 1303 | 1318 |
| 1304 { | 1319 { |
| 1305 window2_->SetBounds(gfx::Rect(121, 199, 10, 20)); | 1320 window2_->SetBounds(gfx::Rect(121, 199, 10, 20)); |
| 1306 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1321 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1307 window_.get(), gfx::Point(), HTTOPRIGHT, | 1322 window_.get(), gfx::Point(), HTTOPRIGHT)); |
| 1308 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1309 ASSERT_TRUE(resizer.get()); | 1323 ASSERT_TRUE(resizer.get()); |
| 1310 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1324 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
| 1311 EXPECT_EQ("100,199 21x31", window_->bounds().ToString()); | 1325 EXPECT_EQ("100,199 21x31", window_->bounds().ToString()); |
| 1312 resizer->RevertDrag(); | 1326 resizer->RevertDrag(); |
| 1313 } | 1327 } |
| 1314 } | 1328 } |
| 1315 | 1329 |
| 1316 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_RIGHT) { | 1330 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_RIGHT) { |
| 1317 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1331 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
| 1318 window2_->SetBounds(gfx::Rect(121, 199, 10, 20)); | 1332 window2_->SetBounds(gfx::Rect(121, 199, 10, 20)); |
| 1319 window2_->Show(); | 1333 window2_->Show(); |
| 1320 | 1334 |
| 1321 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1335 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1322 window_.get(), gfx::Point(), HTRIGHT, | 1336 window_.get(), gfx::Point(), HTRIGHT)); |
| 1323 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1324 ASSERT_TRUE(resizer.get()); | 1337 ASSERT_TRUE(resizer.get()); |
| 1325 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1338 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
| 1326 EXPECT_EQ("100,200 21x30", window_->bounds().ToString()); | 1339 EXPECT_EQ("100,200 21x30", window_->bounds().ToString()); |
| 1327 } | 1340 } |
| 1328 | 1341 |
| 1329 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_BOTTOMRIGHT) { | 1342 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_BOTTOMRIGHT) { |
| 1330 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1343 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
| 1331 window2_->Show(); | 1344 window2_->Show(); |
| 1332 | 1345 |
| 1333 { | 1346 { |
| 1334 window2_->SetBounds(gfx::Rect(122, 212, 10, 20)); | 1347 window2_->SetBounds(gfx::Rect(122, 212, 10, 20)); |
| 1335 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1348 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1336 window_.get(), gfx::Point(), HTBOTTOMRIGHT, | 1349 window_.get(), gfx::Point(), HTBOTTOMRIGHT)); |
| 1337 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1338 ASSERT_TRUE(resizer.get()); | 1350 ASSERT_TRUE(resizer.get()); |
| 1339 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1351 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
| 1340 EXPECT_EQ("100,200 22x32", window_->bounds().ToString()); | 1352 EXPECT_EQ("100,200 22x32", window_->bounds().ToString()); |
| 1341 resizer->RevertDrag(); | 1353 resizer->RevertDrag(); |
| 1342 } | 1354 } |
| 1343 | 1355 |
| 1344 { | 1356 { |
| 1345 window2_->SetBounds(gfx::Rect(111, 233, 10, 20)); | 1357 window2_->SetBounds(gfx::Rect(111, 233, 10, 20)); |
| 1346 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1358 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1347 window_.get(), gfx::Point(), HTBOTTOMRIGHT, | 1359 window_.get(), gfx::Point(), HTBOTTOMRIGHT)); |
| 1348 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1349 ASSERT_TRUE(resizer.get()); | 1360 ASSERT_TRUE(resizer.get()); |
| 1350 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1361 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
| 1351 EXPECT_EQ("100,200 21x33", window_->bounds().ToString()); | 1362 EXPECT_EQ("100,200 21x33", window_->bounds().ToString()); |
| 1352 resizer->RevertDrag(); | 1363 resizer->RevertDrag(); |
| 1353 } | 1364 } |
| 1354 } | 1365 } |
| 1355 | 1366 |
| 1356 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_BOTTOM) { | 1367 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_BOTTOM) { |
| 1357 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1368 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
| 1358 window2_->SetBounds(gfx::Rect(111, 233, 10, 20)); | 1369 window2_->SetBounds(gfx::Rect(111, 233, 10, 20)); |
| 1359 window2_->Show(); | 1370 window2_->Show(); |
| 1360 | 1371 |
| 1361 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1372 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1362 window_.get(), gfx::Point(), HTBOTTOM, | 1373 window_.get(), gfx::Point(), HTBOTTOM)); |
| 1363 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1364 ASSERT_TRUE(resizer.get()); | 1374 ASSERT_TRUE(resizer.get()); |
| 1365 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1375 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
| 1366 EXPECT_EQ("100,200 20x33", window_->bounds().ToString()); | 1376 EXPECT_EQ("100,200 20x33", window_->bounds().ToString()); |
| 1367 } | 1377 } |
| 1368 | 1378 |
| 1369 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_BOTTOMLEFT) { | 1379 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_BOTTOMLEFT) { |
| 1370 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1380 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
| 1371 window2_->Show(); | 1381 window2_->Show(); |
| 1372 | 1382 |
| 1373 { | 1383 { |
| 1374 window2_->SetBounds(gfx::Rect(99, 231, 10, 20)); | 1384 window2_->SetBounds(gfx::Rect(99, 231, 10, 20)); |
| 1375 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1385 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1376 window_.get(), gfx::Point(), HTBOTTOMLEFT, | 1386 window_.get(), gfx::Point(), HTBOTTOMLEFT)); |
| 1377 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1378 ASSERT_TRUE(resizer.get()); | 1387 ASSERT_TRUE(resizer.get()); |
| 1379 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1388 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
| 1380 EXPECT_EQ("99,200 21x31", window_->bounds().ToString()); | 1389 EXPECT_EQ("99,200 21x31", window_->bounds().ToString()); |
| 1381 resizer->RevertDrag(); | 1390 resizer->RevertDrag(); |
| 1382 } | 1391 } |
| 1383 | 1392 |
| 1384 { | 1393 { |
| 1385 window2_->SetBounds(gfx::Rect(89, 209, 10, 20)); | 1394 window2_->SetBounds(gfx::Rect(89, 209, 10, 20)); |
| 1386 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1395 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1387 window_.get(), gfx::Point(), HTBOTTOMLEFT, | 1396 window_.get(), gfx::Point(), HTBOTTOMLEFT)); |
| 1388 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1389 ASSERT_TRUE(resizer.get()); | 1397 ASSERT_TRUE(resizer.get()); |
| 1390 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1398 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
| 1391 EXPECT_EQ("99,200 21x29", window_->bounds().ToString()); | 1399 EXPECT_EQ("99,200 21x29", window_->bounds().ToString()); |
| 1392 resizer->RevertDrag(); | 1400 resizer->RevertDrag(); |
| 1393 } | 1401 } |
| 1394 } | 1402 } |
| 1395 | 1403 |
| 1396 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_LEFT) { | 1404 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_LEFT) { |
| 1397 window2_->SetBounds(gfx::Rect(89, 209, 10, 20)); | 1405 window2_->SetBounds(gfx::Rect(89, 209, 10, 20)); |
| 1398 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1406 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
| 1399 window2_->Show(); | 1407 window2_->Show(); |
| 1400 | 1408 |
| 1401 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1409 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1402 window_.get(), gfx::Point(), HTLEFT, | 1410 window_.get(), gfx::Point(), HTLEFT)); |
| 1403 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1404 ASSERT_TRUE(resizer.get()); | 1411 ASSERT_TRUE(resizer.get()); |
| 1405 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1412 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
| 1406 EXPECT_EQ("99,200 21x30", window_->bounds().ToString()); | 1413 EXPECT_EQ("99,200 21x30", window_->bounds().ToString()); |
| 1407 } | 1414 } |
| 1408 | 1415 |
| 1409 // Test that the user user moved window flag is getting properly set. | 1416 // Test that the user user moved window flag is getting properly set. |
| 1410 TEST_F(WorkspaceWindowResizerTest, CheckUserWindowMangedFlags) { | 1417 TEST_F(WorkspaceWindowResizerTest, CheckUserWindowManagedFlags) { |
| 1411 window_->SetBounds(gfx::Rect( 0, 50, 400, 200)); | 1418 window_->SetBounds(gfx::Rect( 0, 50, 400, 200)); |
| 1412 | 1419 |
| 1413 std::vector<aura::Window*> no_attached_windows; | 1420 std::vector<aura::Window*> no_attached_windows; |
| 1414 // Check that an abort doesn't change anything. | 1421 // Check that an abort doesn't change anything. |
| 1415 { | 1422 { |
| 1416 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1423 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1417 window_.get(), gfx::Point(), HTCAPTION, | 1424 window_.get(), gfx::Point(), HTCAPTION)); |
| 1418 aura::client::WINDOW_MOVE_SOURCE_MOUSE, no_attached_windows)); | |
| 1419 ASSERT_TRUE(resizer.get()); | 1425 ASSERT_TRUE(resizer.get()); |
| 1420 // Move it 100 to the bottom. | 1426 // Move it 100 to the bottom. |
| 1421 resizer->Drag(CalculateDragPoint(*resizer, 0, 100), 0); | 1427 resizer->Drag(CalculateDragPoint(*resizer, 0, 100), 0); |
| 1422 EXPECT_EQ("0,150 400x200", window_->bounds().ToString()); | 1428 EXPECT_EQ("0,150 400x200", window_->bounds().ToString()); |
| 1423 resizer->RevertDrag(); | 1429 resizer->RevertDrag(); |
| 1424 | 1430 |
| 1425 EXPECT_FALSE(wm::GetWindowState(window_.get())->bounds_changed_by_user()); | 1431 EXPECT_FALSE(wm::GetWindowState(window_.get())->bounds_changed_by_user()); |
| 1426 } | 1432 } |
| 1427 | 1433 |
| 1428 // Check that a completed move / size does change the user coordinates. | 1434 // Check that a completed move / size does change the user coordinates. |
| 1429 { | 1435 { |
| 1430 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1436 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1431 window_.get(), gfx::Point(), HTCAPTION, | 1437 window_.get(), gfx::Point(), HTCAPTION)); |
| 1432 aura::client::WINDOW_MOVE_SOURCE_MOUSE, no_attached_windows)); | |
| 1433 ASSERT_TRUE(resizer.get()); | 1438 ASSERT_TRUE(resizer.get()); |
| 1434 // Move it 100 to the bottom. | 1439 // Move it 100 to the bottom. |
| 1435 resizer->Drag(CalculateDragPoint(*resizer, 0, 100), 0); | 1440 resizer->Drag(CalculateDragPoint(*resizer, 0, 100), 0); |
| 1436 EXPECT_EQ("0,150 400x200", window_->bounds().ToString()); | 1441 EXPECT_EQ("0,150 400x200", window_->bounds().ToString()); |
| 1437 resizer->CompleteDrag(0); | 1442 resizer->CompleteDrag(0); |
| 1438 EXPECT_TRUE(wm::GetWindowState(window_.get())->bounds_changed_by_user()); | 1443 EXPECT_TRUE(wm::GetWindowState(window_.get())->bounds_changed_by_user()); |
| 1439 } | 1444 } |
| 1440 } | 1445 } |
| 1441 | 1446 |
| 1442 // Test that a window with a specified max size doesn't exceed it when dragged. | 1447 // Test that a window with a specified max size doesn't exceed it when dragged. |
| 1443 TEST_F(WorkspaceWindowResizerTest, TestMaxSizeEnforced) { | 1448 TEST_F(WorkspaceWindowResizerTest, TestMaxSizeEnforced) { |
| 1444 window_->SetBounds(gfx::Rect(0, 0, 400, 300)); | 1449 window_->SetBounds(gfx::Rect(0, 0, 400, 300)); |
| 1445 delegate_.set_max_size(gfx::Size(401, 301)); | 1450 delegate_.set_max_size(gfx::Size(401, 301)); |
| 1446 | 1451 |
| 1447 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1452 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1448 window_.get(), gfx::Point(), HTBOTTOMRIGHT, | 1453 window_.get(), gfx::Point(), HTBOTTOMRIGHT)); |
| 1449 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1450 resizer->Drag(CalculateDragPoint(*resizer, 2, 2), 0); | 1454 resizer->Drag(CalculateDragPoint(*resizer, 2, 2), 0); |
| 1451 EXPECT_EQ(401, window_->bounds().width()); | 1455 EXPECT_EQ(401, window_->bounds().width()); |
| 1452 EXPECT_EQ(301, window_->bounds().height()); | 1456 EXPECT_EQ(301, window_->bounds().height()); |
| 1453 } | 1457 } |
| 1454 | 1458 |
| 1455 // Test that a window with a specified max width doesn't restrict its height. | 1459 // Test that a window with a specified max width doesn't restrict its height. |
| 1456 TEST_F(WorkspaceWindowResizerTest, TestPartialMaxSizeEnforced) { | 1460 TEST_F(WorkspaceWindowResizerTest, TestPartialMaxSizeEnforced) { |
| 1457 window_->SetBounds(gfx::Rect(0, 0, 400, 300)); | 1461 window_->SetBounds(gfx::Rect(0, 0, 400, 300)); |
| 1458 delegate_.set_max_size(gfx::Size(401, 0)); | 1462 delegate_.set_max_size(gfx::Size(401, 0)); |
| 1459 | 1463 |
| 1460 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1464 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1461 window_.get(), gfx::Point(), HTBOTTOMRIGHT, | 1465 window_.get(), gfx::Point(), HTBOTTOMRIGHT)); |
| 1462 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1463 resizer->Drag(CalculateDragPoint(*resizer, 2, 2), 0); | 1466 resizer->Drag(CalculateDragPoint(*resizer, 2, 2), 0); |
| 1464 EXPECT_EQ(401, window_->bounds().width()); | 1467 EXPECT_EQ(401, window_->bounds().width()); |
| 1465 EXPECT_EQ(302, window_->bounds().height()); | 1468 EXPECT_EQ(302, window_->bounds().height()); |
| 1466 } | 1469 } |
| 1467 | 1470 |
| 1468 // Test that a window with a specified max size can't be snapped. | 1471 // Test that a window with a specified max size can't be snapped. |
| 1469 TEST_F(WorkspaceWindowResizerTest, PhantomSnapMaxSize) { | 1472 TEST_F(WorkspaceWindowResizerTest, PhantomSnapMaxSize) { |
| 1470 { | 1473 { |
| 1471 // With max size not set we get a phantom window controller for dragging off | 1474 // With max size not set we get a phantom window controller for dragging off |
| 1472 // the right hand side. | 1475 // the right hand side. |
| 1473 window_->SetBounds(gfx::Rect(0, 0, 300, 200)); | 1476 // Make the window wider than maximum docked width. |
| 1477 window_->SetBounds(gfx::Rect(0, 0, 400, 200)); | |
| 1474 | 1478 |
| 1475 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1479 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1476 window_.get(), gfx::Point(), HTCAPTION, | 1480 window_.get(), gfx::Point(), HTCAPTION)); |
| 1477 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | 1481 EXPECT_FALSE(snap_phantom_window_controller()); |
| 1478 EXPECT_FALSE(resizer->snap_phantom_window_controller_.get()); | |
| 1479 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0); | 1482 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0); |
| 1480 EXPECT_TRUE(resizer->snap_phantom_window_controller_.get()); | 1483 EXPECT_TRUE(snap_phantom_window_controller()); |
| 1484 resizer->RevertDrag(); | |
| 1481 } | 1485 } |
| 1482 { | 1486 { |
| 1483 // With max size defined, we get no phantom window. | 1487 // With max size defined, we get no phantom window for snapping but we still |
| 1484 window_->SetBounds(gfx::Rect(0, 0, 300, 200)); | 1488 // get a phantom window (docking guide). |
| 1485 delegate_.set_max_size(gfx::Size(300, 200)); | 1489 window_->SetBounds(gfx::Rect(0, 0, 400, 200)); |
| 1490 delegate_.set_max_size(gfx::Size(400, 200)); | |
| 1486 | 1491 |
| 1487 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1492 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1488 window_.get(), gfx::Point(), HTCAPTION, | 1493 window_.get(), gfx::Point(), HTCAPTION)); |
| 1489 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1490 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0); | 1494 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0); |
| 1491 EXPECT_FALSE(resizer->snap_phantom_window_controller_.get()); | 1495 if (switches::UseDockedWindows()) |
| 1496 EXPECT_TRUE(snap_phantom_window_controller()); | |
| 1497 else | |
| 1498 EXPECT_FALSE(snap_phantom_window_controller()); | |
| 1499 resizer->RevertDrag(); | |
| 1500 } | |
| 1501 { | |
| 1502 // With max size defined, we get no phantom window for snapping. | |
| 1503 window_->SetBounds(gfx::Rect(0, 0, 400, 200)); | |
| 1504 delegate_.set_max_size(gfx::Size(400, 200)); | |
| 1505 // With min size defined, we get no phantom window for docking. | |
| 1506 delegate_.set_min_size(gfx::Size(400, 200)); | |
| 1507 | |
| 1508 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | |
| 1509 window_.get(), gfx::Point(), HTCAPTION)); | |
| 1510 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0); | |
| 1511 EXPECT_FALSE(snap_phantom_window_controller()); | |
| 1512 resizer->RevertDrag(); | |
| 1492 } | 1513 } |
| 1493 } | 1514 } |
| 1494 | 1515 |
| 1495 TEST_F(WorkspaceWindowResizerTest, DontRewardRightmostWindowForOverflows) { | 1516 TEST_F(WorkspaceWindowResizerTest, DontRewardRightmostWindowForOverflows) { |
| 1496 UpdateDisplay("600x800"); | 1517 UpdateDisplay("600x800"); |
| 1497 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1518 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 1498 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1519 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
| 1499 | 1520 |
| 1500 // Four 100x100 windows flush against eachother, starting at 100,100. | 1521 // Four 100x100 windows flush against eachother, starting at 100,100. |
| 1501 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1522 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1870 TEST_F(WorkspaceWindowResizerTest, PhantomWindowShow) { | 1891 TEST_F(WorkspaceWindowResizerTest, PhantomWindowShow) { |
| 1871 if (!SupportsMultipleDisplays()) | 1892 if (!SupportsMultipleDisplays()) |
| 1872 return; | 1893 return; |
| 1873 | 1894 |
| 1874 UpdateDisplay("500x400,500x400"); | 1895 UpdateDisplay("500x400,500x400"); |
| 1875 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), | 1896 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), |
| 1876 Shell::GetScreen()->GetPrimaryDisplay()); | 1897 Shell::GetScreen()->GetPrimaryDisplay()); |
| 1877 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 1898 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 1878 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 1899 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
| 1879 | 1900 |
| 1880 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1901 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1881 window_.get(), gfx::Point(0,0), HTCAPTION, | 1902 window_.get(), gfx::Point(), HTCAPTION)); |
| 1882 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); | |
| 1883 ASSERT_TRUE(resizer.get()); | 1903 ASSERT_TRUE(resizer.get()); |
| 1884 EXPECT_FALSE(resizer->snap_phantom_window_controller_.get()); | 1904 EXPECT_FALSE(snap_phantom_window_controller()); |
| 1885 | 1905 |
| 1886 // The pointer is on the edge but not shared. The snap phantom window | 1906 // The pointer is on the edge but not shared. The snap phantom window |
| 1887 // controller should be non-NULL. | 1907 // controller should be non-NULL. |
| 1888 resizer->Drag(CalculateDragPoint(*resizer, -1, 0), 0); | 1908 resizer->Drag(CalculateDragPoint(*resizer, -1, 0), 0); |
| 1889 EXPECT_TRUE(resizer->snap_phantom_window_controller_.get()); | 1909 EXPECT_TRUE(snap_phantom_window_controller()); |
| 1890 PhantomWindowController* phantom_controller( | 1910 PhantomWindowController* phantom_controller(snap_phantom_window_controller()); |
| 1891 resizer->snap_phantom_window_controller_.get()); | |
| 1892 | 1911 |
| 1893 // phantom widget only in the left screen. | 1912 // phantom widget only in the left screen. |
| 1894 phantom_controller->Show(gfx::Rect(100, 100, 50, 60)); | 1913 phantom_controller->Show(gfx::Rect(100, 100, 50, 60)); |
| 1895 EXPECT_TRUE(phantom_controller->phantom_widget_); | 1914 EXPECT_TRUE(phantom_controller->phantom_widget_); |
| 1896 EXPECT_FALSE(phantom_controller->phantom_widget_start_); | 1915 EXPECT_FALSE(phantom_controller->phantom_widget_start_); |
| 1897 EXPECT_EQ( | 1916 EXPECT_EQ( |
| 1898 root_windows[0], | 1917 root_windows[0], |
| 1899 phantom_controller->phantom_widget_->GetNativeWindow()->GetRootWindow()); | 1918 phantom_controller->phantom_widget_->GetNativeWindow()->GetRootWindow()); |
| 1900 | 1919 |
| 1901 // Move phantom widget into the right screen. Test that 2 widgets got created. | 1920 // Move phantom widget into the right screen. Test that 2 widgets got created. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1970 RunAnimationTillComplete(phantom_controller->animation_.get()); | 1989 RunAnimationTillComplete(phantom_controller->animation_.get()); |
| 1971 | 1990 |
| 1972 // Hide phantom controller. Both widgets should close. | 1991 // Hide phantom controller. Both widgets should close. |
| 1973 phantom_controller->Hide(); | 1992 phantom_controller->Hide(); |
| 1974 EXPECT_FALSE(phantom_controller->phantom_widget_); | 1993 EXPECT_FALSE(phantom_controller->phantom_widget_); |
| 1975 EXPECT_FALSE(phantom_controller->phantom_widget_start_); | 1994 EXPECT_FALSE(phantom_controller->phantom_widget_start_); |
| 1976 } | 1995 } |
| 1977 | 1996 |
| 1978 } // namespace internal | 1997 } // namespace internal |
| 1979 } // namespace ash | 1998 } // namespace ash |
| OLD | NEW |