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