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

Side by Side Diff: ash/mus/test/wm_test_base.cc

Issue 2642003002: Removes ash::mus::RootWindowController (Closed)
Patch Set: Created 3 years, 11 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/mus/test/wm_test_base.h" 5 #include "ash/mus/test/wm_test_base.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/common/session/session_controller.h" 10 #include "ash/common/session/session_controller.h"
11 #include "ash/common/wm_shell.h" 11 #include "ash/common/wm_shell.h"
12 #include "ash/mus/root_window_controller.h"
13 #include "ash/mus/test/wm_test_helper.h" 12 #include "ash/mus/test/wm_test_helper.h"
13 #include "ash/mus/top_level_window_factory.h"
14 #include "ash/mus/window_manager.h" 14 #include "ash/mus/window_manager.h"
15 #include "ash/mus/window_manager_application.h" 15 #include "ash/mus/window_manager_application.h"
16 #include "ash/public/cpp/session_types.h" 16 #include "ash/public/cpp/session_types.h"
17 #include "ash/public/interfaces/session_controller.mojom.h" 17 #include "ash/public/interfaces/session_controller.mojom.h"
18 #include "ash/test/wm_window_test_api.h" 18 #include "ash/test/wm_window_test_api.h"
19 #include "base/memory/ptr_util.h" 19 #include "base/memory/ptr_util.h"
20 #include "services/ui/public/cpp/property_type_converters.h" 20 #include "services/ui/public/cpp/property_type_converters.h"
21 #include "ui/aura/mus/property_converter.h" 21 #include "ui/aura/mus/property_converter.h"
22 #include "ui/aura/mus/window_tree_client.h" 22 #include "ui/aura/mus/window_tree_client.h"
23 #include "ui/aura/window.h" 23 #include "ui/aura/window.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 74
75 void WmTestBase::UpdateDisplay(const std::string& display_spec) { 75 void WmTestBase::UpdateDisplay(const std::string& display_spec) {
76 test_helper_->UpdateDisplay(display_spec); 76 test_helper_->UpdateDisplay(display_spec);
77 } 77 }
78 78
79 aura::Window* WmTestBase::GetPrimaryRootWindow() { 79 aura::Window* WmTestBase::GetPrimaryRootWindow() {
80 std::vector<RootWindowController*> roots = 80 std::vector<RootWindowController*> roots =
81 test_helper_->GetRootsOrderedByDisplayId(); 81 test_helper_->GetRootsOrderedByDisplayId();
82 DCHECK(!roots.empty()); 82 DCHECK(!roots.empty());
83 return roots[0]->root(); 83 return roots[0]->GetRootWindow();
84 } 84 }
85 85
86 aura::Window* WmTestBase::GetSecondaryRootWindow() { 86 aura::Window* WmTestBase::GetSecondaryRootWindow() {
87 std::vector<RootWindowController*> roots = 87 std::vector<RootWindowController*> roots =
88 test_helper_->GetRootsOrderedByDisplayId(); 88 test_helper_->GetRootsOrderedByDisplayId();
89 return roots.size() < 2 ? nullptr : roots[1]->root(); 89 return roots.size() < 2 ? nullptr : roots[1]->GetRootWindow();
90 } 90 }
91 91
92 display::Display WmTestBase::GetPrimaryDisplay() { 92 display::Display WmTestBase::GetPrimaryDisplay() {
93 std::vector<RootWindowController*> roots = 93 std::vector<RootWindowController*> roots =
94 test_helper_->GetRootsOrderedByDisplayId(); 94 test_helper_->GetRootsOrderedByDisplayId();
95 DCHECK(!roots.empty()); 95 DCHECK(!roots.empty());
96 return roots[0]->display(); 96 return roots[0]->GetWindow()->GetDisplayNearestWindow();
msw 2017/01/18 23:31:27 q: does it matter if we call GetWindow vs. GetRoot
sky 2017/01/19 01:02:19 They are the same thing, with different result val
msw 2017/01/19 01:20:33 Ah, I didn't notice the WmWindow/aura::Window retu
97 } 97 }
98 98
99 display::Display WmTestBase::GetSecondaryDisplay() { 99 display::Display WmTestBase::GetSecondaryDisplay() {
100 std::vector<RootWindowController*> roots = 100 std::vector<RootWindowController*> roots =
101 test_helper_->GetRootsOrderedByDisplayId(); 101 test_helper_->GetRootsOrderedByDisplayId();
102 return roots.size() < 2 ? display::Display() : roots[1]->display(); 102 return roots.size() < 2 ? display::Display()
103 : roots[1]->GetWindow()->GetDisplayNearestWindow();
103 } 104 }
104 105
105 aura::Window* WmTestBase::CreateTestWindow(const gfx::Rect& bounds) { 106 aura::Window* WmTestBase::CreateTestWindow(const gfx::Rect& bounds) {
106 return CreateTestWindow(bounds, ui::wm::WINDOW_TYPE_NORMAL); 107 return CreateTestWindow(bounds, ui::wm::WINDOW_TYPE_NORMAL);
107 } 108 }
108 109
109 aura::Window* WmTestBase::CreateTestWindow(const gfx::Rect& bounds, 110 aura::Window* WmTestBase::CreateTestWindow(const gfx::Rect& bounds,
110 ui::wm::WindowType window_type) { 111 ui::wm::WindowType window_type) {
111 std::map<std::string, std::vector<uint8_t>> properties; 112 std::map<std::string, std::vector<uint8_t>> properties;
112 if (!bounds.IsEmpty()) { 113 if (!bounds.IsEmpty()) {
113 properties[ui::mojom::WindowManager::kBounds_InitProperty] = 114 properties[ui::mojom::WindowManager::kBounds_InitProperty] =
114 mojo::ConvertTo<std::vector<uint8_t>>(bounds); 115 mojo::ConvertTo<std::vector<uint8_t>>(bounds);
115 } 116 }
116 117
117 properties[ui::mojom::WindowManager::kResizeBehavior_Property] = 118 properties[ui::mojom::WindowManager::kResizeBehavior_Property] =
118 mojo::ConvertTo<std::vector<uint8_t>>( 119 mojo::ConvertTo<std::vector<uint8_t>>(
119 static_cast<aura::PropertyConverter::PrimitiveType>( 120 static_cast<aura::PropertyConverter::PrimitiveType>(
120 ui::mojom::kResizeBehaviorCanResize | 121 ui::mojom::kResizeBehaviorCanResize |
121 ui::mojom::kResizeBehaviorCanMaximize | 122 ui::mojom::kResizeBehaviorCanMaximize |
122 ui::mojom::kResizeBehaviorCanMinimize)); 123 ui::mojom::kResizeBehaviorCanMinimize));
123 124
124 const ui::mojom::WindowType mus_window_type = 125 const ui::mojom::WindowType mus_window_type =
125 MusWindowTypeFromWmWindowType(window_type); 126 MusWindowTypeFromWmWindowType(window_type);
126 aura::Window* window = test_helper_->GetRootsOrderedByDisplayId()[0] 127 WindowManager* window_manager =
127 ->window_manager() 128 test_helper_->window_manager_app()->window_manager();
128 ->NewTopLevelWindow(mus_window_type, &properties); 129 aura::Window* window = CreateAndParentTopLevelWindow(
130 window_manager, mus_window_type, &properties);
129 window->Show(); 131 window->Show();
130 return window; 132 return window;
131 } 133 }
132 134
133 aura::Window* WmTestBase::CreateFullscreenTestWindow(int64_t display_id) { 135 aura::Window* WmTestBase::CreateFullscreenTestWindow(int64_t display_id) {
134 std::map<std::string, std::vector<uint8_t>> properties; 136 std::map<std::string, std::vector<uint8_t>> properties;
135 properties[ui::mojom::WindowManager::kShowState_Property] = 137 properties[ui::mojom::WindowManager::kShowState_Property] =
136 mojo::ConvertTo<std::vector<uint8_t>>( 138 mojo::ConvertTo<std::vector<uint8_t>>(
137 static_cast<aura::PropertyConverter::PrimitiveType>( 139 static_cast<aura::PropertyConverter::PrimitiveType>(
138 ui::mojom::ShowState::FULLSCREEN)); 140 ui::mojom::ShowState::FULLSCREEN));
139 if (display_id != display::kInvalidDisplayId) { 141 if (display_id != display::kInvalidDisplayId) {
140 properties[ui::mojom::WindowManager::kDisplayId_InitProperty] = 142 properties[ui::mojom::WindowManager::kDisplayId_InitProperty] =
141 mojo::ConvertTo<std::vector<uint8_t>>(display_id); 143 mojo::ConvertTo<std::vector<uint8_t>>(display_id);
142 } 144 }
143 aura::Window* window = 145 WindowManager* window_manager =
144 test_helper_->GetRootsOrderedByDisplayId()[0] 146 test_helper_->window_manager_app()->window_manager();
145 ->window_manager() 147 aura::Window* window = CreateAndParentTopLevelWindow(
146 ->NewTopLevelWindow(ui::mojom::WindowType::WINDOW, &properties); 148 window_manager, ui::mojom::WindowType::WINDOW, &properties);
147 window->Show(); 149 window->Show();
148 return window; 150 return window;
149 } 151 }
150 152
151 aura::Window* WmTestBase::CreateChildTestWindow(aura::Window* parent, 153 aura::Window* WmTestBase::CreateChildTestWindow(aura::Window* parent,
152 const gfx::Rect& bounds) { 154 const gfx::Rect& bounds) {
153 std::map<std::string, std::vector<uint8_t>> properties; 155 std::map<std::string, std::vector<uint8_t>> properties;
154 aura::Window* window = new aura::Window(nullptr); 156 aura::Window* window = new aura::Window(nullptr);
155 window->Init(ui::LAYER_TEXTURED); 157 window->Init(ui::LAYER_TEXTURED);
156 window->SetBounds(bounds); 158 window->SetBounds(bounds);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 info->can_lock_screen = true; 202 info->can_lock_screen = true;
201 info->should_lock_screen_automatically = false; 203 info->should_lock_screen_automatically = false;
202 info->add_user_session_policy = AddUserSessionPolicy::ALLOWED; 204 info->add_user_session_policy = AddUserSessionPolicy::ALLOWED;
203 info->state = session_manager::SessionState::ACTIVE; 205 info->state = session_manager::SessionState::ACTIVE;
204 session_controller->SetSessionInfo(std::move(info)); 206 session_controller->SetSessionInfo(std::move(info));
205 } 207 }
206 208
207 209
208 } // namespace mus 210 } // namespace mus
209 } // namespace ash 211 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698