| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/common/test/ash_test.h" | 5 #include "ash/common/test/ash_test.h" |
| 6 | 6 |
| 7 #include "ash/common/test/ash_test_impl.h" | 7 #include "ash/common/test/ash_test_impl.h" |
| 8 #include "ash/common/wm_root_window_controller.h" |
| 8 #include "ash/common/wm_shell.h" | 9 #include "ash/common/wm_shell.h" |
| 9 #include "ash/common/wm_window.h" | 10 #include "ash/common/wm_window.h" |
| 11 #include "ash/test/test_session_state_delegate.h" |
| 12 #include "base/run_loop.h" |
| 10 #include "ui/compositor/layer_type.h" | 13 #include "ui/compositor/layer_type.h" |
| 11 #include "ui/display/display.h" | 14 #include "ui/display/display.h" |
| 12 | 15 |
| 13 namespace ash { | 16 namespace ash { |
| 14 | 17 |
| 15 WindowOwner::WindowOwner(WmWindow* window) : window_(window) {} | 18 WindowOwner::WindowOwner(WmWindow* window) : window_(window) {} |
| 16 | 19 |
| 17 WindowOwner::~WindowOwner() { | 20 WindowOwner::~WindowOwner() { |
| 18 window_->Destroy(); | 21 window_->Destroy(); |
| 19 } | 22 } |
| 20 | 23 |
| 21 AshTest::AshTest() : test_impl_(AshTestImpl::Create()) {} | 24 AshTest::AshTest() : test_impl_(AshTestImpl::Create()) {} |
| 22 | 25 |
| 23 AshTest::~AshTest() {} | 26 AshTest::~AshTest() {} |
| 24 | 27 |
| 28 // static |
| 29 WmShelf* AshTest::GetPrimaryShelf() { |
| 30 return WmShell::Get() |
| 31 ->GetPrimaryRootWindow() |
| 32 ->GetRootWindowController() |
| 33 ->GetShelf(); |
| 34 } |
| 35 |
| 25 bool AshTest::SupportsMultipleDisplays() const { | 36 bool AshTest::SupportsMultipleDisplays() const { |
| 26 return test_impl_->SupportsMultipleDisplays(); | 37 return test_impl_->SupportsMultipleDisplays(); |
| 27 } | 38 } |
| 28 | 39 |
| 29 void AshTest::UpdateDisplay(const std::string& display_spec) { | 40 void AshTest::UpdateDisplay(const std::string& display_spec) { |
| 30 return test_impl_->UpdateDisplay(display_spec); | 41 return test_impl_->UpdateDisplay(display_spec); |
| 31 } | 42 } |
| 32 | 43 |
| 33 std::unique_ptr<WindowOwner> AshTest::CreateTestWindow(const gfx::Rect& bounds, | 44 std::unique_ptr<WindowOwner> AshTest::CreateTestWindow(const gfx::Rect& bounds, |
| 34 ui::wm::WindowType type, | 45 ui::wm::WindowType type, |
| 35 int shell_window_id) { | 46 int shell_window_id) { |
| 36 return test_impl_->CreateTestWindow(bounds, type, shell_window_id); | 47 return test_impl_->CreateTestWindow(bounds, type, shell_window_id); |
| 37 } | 48 } |
| 38 | 49 |
| 50 std::unique_ptr<WindowOwner> AshTest::CreateToplevelTestWindow( |
| 51 const gfx::Rect& bounds_in_screen, |
| 52 int shell_window_id) { |
| 53 return test_impl_->CreateToplevelTestWindow(bounds_in_screen, |
| 54 shell_window_id); |
| 55 } |
| 56 |
| 39 std::unique_ptr<WindowOwner> AshTest::CreateChildWindow(WmWindow* parent, | 57 std::unique_ptr<WindowOwner> AshTest::CreateChildWindow(WmWindow* parent, |
| 40 const gfx::Rect& bounds, | 58 const gfx::Rect& bounds, |
| 41 int shell_window_id) { | 59 int shell_window_id) { |
| 42 std::unique_ptr<WindowOwner> window_owner = | 60 std::unique_ptr<WindowOwner> window_owner = |
| 43 base::MakeUnique<WindowOwner>(WmShell::Get()->NewWindow( | 61 base::MakeUnique<WindowOwner>(WmShell::Get()->NewWindow( |
| 44 ui::wm::WINDOW_TYPE_NORMAL, ui::LAYER_NOT_DRAWN)); | 62 ui::wm::WINDOW_TYPE_NORMAL, ui::LAYER_NOT_DRAWN)); |
| 45 window_owner->window()->SetBounds(bounds); | 63 window_owner->window()->SetBounds(bounds); |
| 46 window_owner->window()->SetShellWindowId(shell_window_id); | 64 window_owner->window()->SetShellWindowId(shell_window_id); |
| 47 parent->AddChild(window_owner->window()); | 65 parent->AddChild(window_owner->window()); |
| 48 window_owner->window()->Show(); | 66 window_owner->window()->Show(); |
| 49 return window_owner; | 67 return window_owner; |
| 50 } | 68 } |
| 51 | 69 |
| 52 display::Display AshTest::GetSecondaryDisplay() { | 70 display::Display AshTest::GetSecondaryDisplay() { |
| 53 return test_impl_->GetSecondaryDisplay(); | 71 return test_impl_->GetSecondaryDisplay(); |
| 54 } | 72 } |
| 55 | 73 |
| 56 bool AshTest::SetSecondaryDisplayPlacement( | 74 bool AshTest::SetSecondaryDisplayPlacement( |
| 57 display::DisplayPlacement::Position position, | 75 display::DisplayPlacement::Position position, |
| 58 int offset) { | 76 int offset) { |
| 59 return test_impl_->SetSecondaryDisplayPlacement(position, offset); | 77 return test_impl_->SetSecondaryDisplayPlacement(position, offset); |
| 60 } | 78 } |
| 61 | 79 |
| 80 void AshTest::ConfigureWidgetInitParamsForDisplay( |
| 81 WmWindow* window, |
| 82 views::Widget::InitParams* init_params) { |
| 83 test_impl_->ConfigureWidgetInitParamsForDisplay(window, init_params); |
| 84 } |
| 85 |
| 86 void AshTest::ParentWindowInPrimaryRootWindow(WmWindow* window) { |
| 87 window->SetParentUsingContext(WmShell::Get()->GetPrimaryRootWindow(), |
| 88 gfx::Rect()); |
| 89 } |
| 90 |
| 91 void AshTest::AddTransientChild(WmWindow* parent, WmWindow* window) { |
| 92 test_impl_->AddTransientChild(parent, window); |
| 93 } |
| 94 |
| 95 void AshTest::RunAllPendingInMessageLoop() { |
| 96 base::RunLoop run_loop; |
| 97 run_loop.RunUntilIdle(); |
| 98 } |
| 99 |
| 62 void AshTest::SetUp() { | 100 void AshTest::SetUp() { |
| 63 test_impl_->SetUp(); | 101 test_impl_->SetUp(); |
| 64 } | 102 } |
| 65 | 103 |
| 66 void AshTest::TearDown() { | 104 void AshTest::TearDown() { |
| 67 test_impl_->TearDown(); | 105 test_impl_->TearDown(); |
| 68 } | 106 } |
| 69 | 107 |
| 70 } // namespace ash | 108 } // namespace ash |
| OLD | NEW |