Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: ash/common/test/ash_test.cc

Issue 2391153002: Converts most of WorkspaceLayoutManager tests to use common code (Closed)
Patch Set: merge Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 bool AshTest::IsRunningInMash() {
30 return WmShell::Get()->IsRunningInMash();
31 }
32
33 // static
34 WmShelf* AshTest::GetPrimaryShelf() {
35 return WmShell::Get()
36 ->GetPrimaryRootWindow()
37 ->GetRootWindowController()
38 ->GetShelf();
39 }
40
25 bool AshTest::SupportsMultipleDisplays() const { 41 bool AshTest::SupportsMultipleDisplays() const {
26 return test_impl_->SupportsMultipleDisplays(); 42 return test_impl_->SupportsMultipleDisplays();
27 } 43 }
28 44
29 void AshTest::UpdateDisplay(const std::string& display_spec) { 45 void AshTest::UpdateDisplay(const std::string& display_spec) {
30 return test_impl_->UpdateDisplay(display_spec); 46 return test_impl_->UpdateDisplay(display_spec);
31 } 47 }
32 48
33 std::unique_ptr<WindowOwner> AshTest::CreateTestWindow(const gfx::Rect& bounds, 49 std::unique_ptr<WindowOwner> AshTest::CreateTestWindow(const gfx::Rect& bounds,
34 ui::wm::WindowType type, 50 ui::wm::WindowType type,
35 int shell_window_id) { 51 int shell_window_id) {
36 return test_impl_->CreateTestWindow(bounds, type, shell_window_id); 52 return test_impl_->CreateTestWindow(bounds, type, shell_window_id);
37 } 53 }
38 54
55 std::unique_ptr<WindowOwner> AshTest::CreateToplevelTestWindow(
56 const gfx::Rect& bounds_in_screen,
57 int shell_window_id) {
58 return test_impl_->CreateToplevelTestWindow(bounds_in_screen,
59 shell_window_id);
60 }
61
39 std::unique_ptr<WindowOwner> AshTest::CreateChildWindow(WmWindow* parent, 62 std::unique_ptr<WindowOwner> AshTest::CreateChildWindow(WmWindow* parent,
40 const gfx::Rect& bounds, 63 const gfx::Rect& bounds,
41 int shell_window_id) { 64 int shell_window_id) {
42 std::unique_ptr<WindowOwner> window_owner = 65 std::unique_ptr<WindowOwner> window_owner =
43 base::MakeUnique<WindowOwner>(WmShell::Get()->NewWindow( 66 base::MakeUnique<WindowOwner>(WmShell::Get()->NewWindow(
44 ui::wm::WINDOW_TYPE_NORMAL, ui::LAYER_NOT_DRAWN)); 67 ui::wm::WINDOW_TYPE_NORMAL, ui::LAYER_NOT_DRAWN));
45 window_owner->window()->SetBounds(bounds); 68 window_owner->window()->SetBounds(bounds);
46 window_owner->window()->SetShellWindowId(shell_window_id); 69 window_owner->window()->SetShellWindowId(shell_window_id);
47 parent->AddChild(window_owner->window()); 70 parent->AddChild(window_owner->window());
48 window_owner->window()->Show(); 71 window_owner->window()->Show();
49 return window_owner; 72 return window_owner;
50 } 73 }
51 74
52 display::Display AshTest::GetSecondaryDisplay() { 75 display::Display AshTest::GetSecondaryDisplay() {
53 return test_impl_->GetSecondaryDisplay(); 76 return test_impl_->GetSecondaryDisplay();
54 } 77 }
55 78
56 bool AshTest::SetSecondaryDisplayPlacement( 79 bool AshTest::SetSecondaryDisplayPlacement(
57 display::DisplayPlacement::Position position, 80 display::DisplayPlacement::Position position,
58 int offset) { 81 int offset) {
59 return test_impl_->SetSecondaryDisplayPlacement(position, offset); 82 return test_impl_->SetSecondaryDisplayPlacement(position, offset);
60 } 83 }
61 84
85 void AshTest::ConfigureWidgetInitParamsForDisplay(
86 WmWindow* window,
87 views::Widget::InitParams* init_params) {
88 test_impl_->ConfigureWidgetInitParamsForDisplay(window, init_params);
89 }
90
91 void AshTest::ParentWindowInPrimaryRootWindow(WmWindow* window) {
92 window->SetParentUsingContext(WmShell::Get()->GetPrimaryRootWindow(),
93 gfx::Rect());
94 }
95
96 void AshTest::AddTransientChild(WmWindow* parent, WmWindow* window) {
97 test_impl_->AddTransientChild(parent, window);
98 }
99
100 void AshTest::SetCanLockScreen(bool can_lock_screen) {
101 CHECK(WmShell::HasInstance());
102 static_cast<ash::test::TestSessionStateDelegate*>(
103 WmShell::Get()->GetSessionStateDelegate())
104 ->SetCanLockScreen(can_lock_screen);
105 }
106
107 void AshTest::RunAllPendingInMessageLoop() {
108 base::RunLoop run_loop;
109 run_loop.RunUntilIdle();
110 }
111
62 void AshTest::SetUp() { 112 void AshTest::SetUp() {
63 test_impl_->SetUp(); 113 test_impl_->SetUp();
64 } 114 }
65 115
66 void AshTest::TearDown() { 116 void AshTest::TearDown() {
67 test_impl_->TearDown(); 117 test_impl_->TearDown();
68 } 118 }
69 119
70 } // namespace ash 120 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698