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