| 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/screen_ash.h" | 7 #include "ash/screen_ash.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 10 #include "ash/wm/property_util.h" | 10 #include "ash/wm/property_util.h" |
| 11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
| 12 #include "ui/aura/root_window.h" | 12 #include "ui/aura/root_window.h" |
| 13 #include "ui/aura/test/test_window_delegate.h" | 13 #include "ui/aura/test/test_window_delegate.h" |
| 14 #include "ui/base/hit_test.h" | 14 #include "ui/base/hit_test.h" |
| 15 #include "ui/gfx/insets.h" |
| 15 | 16 |
| 16 namespace ash { | 17 namespace ash { |
| 17 namespace internal { | 18 namespace internal { |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 const int kRootHeight = 600; | 21 const int kRootHeight = 600; |
| 21 | 22 |
| 22 // A simple window delegate that returns the specified min size. | 23 // A simple window delegate that returns the specified min size. |
| 23 class TestWindowDelegate : public aura::test::TestWindowDelegate { | 24 class TestWindowDelegate : public aura::test::TestWindowDelegate { |
| 24 public: | 25 public: |
| (...skipping 20 matching lines...) Expand all Loading... |
| 45 public: | 46 public: |
| 46 WorkspaceWindowResizerTest() : window_(NULL) {} | 47 WorkspaceWindowResizerTest() : window_(NULL) {} |
| 47 virtual ~WorkspaceWindowResizerTest() {} | 48 virtual ~WorkspaceWindowResizerTest() {} |
| 48 | 49 |
| 49 virtual void SetUp() OVERRIDE { | 50 virtual void SetUp() OVERRIDE { |
| 50 AshTestBase::SetUp(); | 51 AshTestBase::SetUp(); |
| 51 aura::RootWindow* root = Shell::GetInstance()->GetRootWindow(); | 52 aura::RootWindow* root = Shell::GetInstance()->GetRootWindow(); |
| 52 root->SetBounds(gfx::Rect(0, 0, 800, kRootHeight)); | 53 root->SetBounds(gfx::Rect(0, 0, 800, kRootHeight)); |
| 53 gfx::Rect root_bounds(root->bounds()); | 54 gfx::Rect root_bounds(root->bounds()); |
| 54 EXPECT_EQ(kRootHeight, root_bounds.height()); | 55 EXPECT_EQ(kRootHeight, root_bounds.height()); |
| 55 Shell::GetInstance()->SetScreenWorkAreaInsets(gfx::Insets()); | 56 Shell::GetInstance()->SetMonitorWorkAreaInsets(root, gfx::Insets()); |
| 56 window_.reset(new aura::Window(&delegate_)); | 57 window_.reset(new aura::Window(&delegate_)); |
| 57 window_->Init(ui::Layer::LAYER_NOT_DRAWN); | 58 window_->Init(ui::Layer::LAYER_NOT_DRAWN); |
| 58 window_->SetParent(Shell::GetInstance()->GetRootWindow()); | 59 window_->SetParent(Shell::GetInstance()->GetRootWindow()); |
| 59 | 60 |
| 60 window2_.reset(new aura::Window(&delegate2_)); | 61 window2_.reset(new aura::Window(&delegate2_)); |
| 61 window2_->Init(ui::Layer::LAYER_NOT_DRAWN); | 62 window2_->Init(ui::Layer::LAYER_NOT_DRAWN); |
| 62 window2_->SetParent(Shell::GetInstance()->GetRootWindow()); | 63 window2_->SetParent(Shell::GetInstance()->GetRootWindow()); |
| 63 | 64 |
| 64 window3_.reset(new aura::Window(&delegate3_)); | 65 window3_.reset(new aura::Window(&delegate3_)); |
| 65 window3_->Init(ui::Layer::LAYER_NOT_DRAWN); | 66 window3_->Init(ui::Layer::LAYER_NOT_DRAWN); |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 EXPECT_EQ("0,0 400x380", window_->bounds().ToString()); | 541 EXPECT_EQ("0,0 400x380", window_->bounds().ToString()); |
| 541 EXPECT_EQ("40,380 100x200", window2_->bounds().ToString()); | 542 EXPECT_EQ("40,380 100x200", window2_->bounds().ToString()); |
| 542 } | 543 } |
| 543 } | 544 } |
| 544 | 545 |
| 545 // Assertions around attached window resize dragging from the bottom with 3 | 546 // Assertions around attached window resize dragging from the bottom with 3 |
| 546 // windows. | 547 // windows. |
| 547 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_3) { | 548 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_3) { |
| 548 aura::RootWindow* root = Shell::GetInstance()->GetRootWindow(); | 549 aura::RootWindow* root = Shell::GetInstance()->GetRootWindow(); |
| 549 root->SetBounds(gfx::Rect(0, 0, 600, 800)); | 550 root->SetBounds(gfx::Rect(0, 0, 600, 800)); |
| 550 Shell::GetInstance()->SetScreenWorkAreaInsets(gfx::Insets()); | 551 Shell::GetInstance()->SetMonitorWorkAreaInsets(root, gfx::Insets()); |
| 551 | 552 |
| 552 window_->SetBounds(gfx::Rect( 300, 100, 300, 200)); | 553 window_->SetBounds(gfx::Rect( 300, 100, 300, 200)); |
| 553 window2_->SetBounds(gfx::Rect(300, 300, 200, 150)); | 554 window2_->SetBounds(gfx::Rect(300, 300, 200, 150)); |
| 554 window3_->SetBounds(gfx::Rect(300, 450, 200, 100)); | 555 window3_->SetBounds(gfx::Rect(300, 450, 200, 100)); |
| 555 delegate2_.set_min_size(gfx::Size(50, 52)); | 556 delegate2_.set_min_size(gfx::Size(50, 52)); |
| 556 delegate3_.set_min_size(gfx::Size(50, 38)); | 557 delegate3_.set_min_size(gfx::Size(50, 38)); |
| 557 | 558 |
| 558 std::vector<aura::Window*> windows; | 559 std::vector<aura::Window*> windows; |
| 559 windows.push_back(window2_.get()); | 560 windows.push_back(window2_.get()); |
| 560 windows.push_back(window3_.get()); | 561 windows.push_back(window3_.get()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 582 // Revert and make sure everything moves back. | 583 // Revert and make sure everything moves back. |
| 583 resizer->RevertDrag(); | 584 resizer->RevertDrag(); |
| 584 EXPECT_EQ("300,100 300x200", window_->bounds().ToString()); | 585 EXPECT_EQ("300,100 300x200", window_->bounds().ToString()); |
| 585 EXPECT_EQ("300,300 200x150", window2_->bounds().ToString()); | 586 EXPECT_EQ("300,300 200x150", window2_->bounds().ToString()); |
| 586 EXPECT_EQ("300,450 200x100", window3_->bounds().ToString()); | 587 EXPECT_EQ("300,450 200x100", window3_->bounds().ToString()); |
| 587 } | 588 } |
| 588 | 589 |
| 589 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_RememberHeight) { | 590 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_RememberHeight) { |
| 590 aura::RootWindow* root = Shell::GetInstance()->GetRootWindow(); | 591 aura::RootWindow* root = Shell::GetInstance()->GetRootWindow(); |
| 591 root->SetBounds(gfx::Rect(0, 0, 600, 800)); | 592 root->SetBounds(gfx::Rect(0, 0, 600, 800)); |
| 592 Shell::GetInstance()->SetScreenWorkAreaInsets(gfx::Insets()); | 593 Shell::GetInstance()->SetMonitorWorkAreaInsets(root, gfx::Insets()); |
| 593 | 594 |
| 594 window_->SetBounds(gfx::Rect( 300, 100, 300, 200)); | 595 window_->SetBounds(gfx::Rect( 300, 100, 300, 200)); |
| 595 window2_->SetBounds(gfx::Rect(300, 300, 200, 150)); | 596 window2_->SetBounds(gfx::Rect(300, 300, 200, 150)); |
| 596 window3_->SetBounds(gfx::Rect(300, 450, 200, 100)); | 597 window3_->SetBounds(gfx::Rect(300, 450, 200, 100)); |
| 597 delegate2_.set_min_size(gfx::Size(50, 52)); | 598 delegate2_.set_min_size(gfx::Size(50, 52)); |
| 598 delegate3_.set_min_size(gfx::Size(50, 38)); | 599 delegate3_.set_min_size(gfx::Size(50, 38)); |
| 599 | 600 |
| 600 std::vector<aura::Window*> windows; | 601 std::vector<aura::Window*> windows; |
| 601 windows.push_back(window2_.get()); | 602 windows.push_back(window2_.get()); |
| 602 windows.push_back(window3_.get()); | 603 windows.push_back(window3_.get()); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 resizer->Drag(CalculateDragPoint(*resizer, 800, 10)); | 658 resizer->Drag(CalculateDragPoint(*resizer, 800, 10)); |
| 658 resizer->CompleteDrag(); | 659 resizer->CompleteDrag(); |
| 659 EXPECT_EQ("400,0 400x600", window_->bounds().ToString()); | 660 EXPECT_EQ("400,0 400x600", window_->bounds().ToString()); |
| 660 ASSERT_TRUE(GetRestoreBounds(window_.get())); | 661 ASSERT_TRUE(GetRestoreBounds(window_.get())); |
| 661 EXPECT_EQ("20,30 50x60", GetRestoreBounds(window_.get())->ToString()); | 662 EXPECT_EQ("20,30 50x60", GetRestoreBounds(window_.get())->ToString()); |
| 662 } | 663 } |
| 663 | 664 |
| 664 } // namespace | 665 } // namespace |
| 665 } // namespace test | 666 } // namespace test |
| 666 } // namespace ash | 667 } // namespace ash |
| OLD | NEW |