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

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

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

Powered by Google App Engine
This is Rietveld 408576698