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

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

Issue 2503623002: Support creation of toplevel mus::Windows on separate displays (Closed)
Patch Set: Fix container root lookup. Don't need to initialize container id for unit test. Created 4 years, 1 month 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/mus/bridge/wm_window_mus_test_api.h" 10 #include "ash/mus/bridge/wm_window_mus_test_api.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 DCHECK(!roots.empty()); 87 DCHECK(!roots.empty());
88 return roots[0]->display(); 88 return roots[0]->display();
89 } 89 }
90 90
91 display::Display WmTestBase::GetSecondaryDisplay() { 91 display::Display WmTestBase::GetSecondaryDisplay() {
92 std::vector<RootWindowController*> roots = 92 std::vector<RootWindowController*> roots =
93 test_helper_->GetRootsOrderedByDisplayId(); 93 test_helper_->GetRootsOrderedByDisplayId();
94 return roots.size() < 2 ? display::Display() : roots[1]->display(); 94 return roots.size() < 2 ? display::Display() : roots[1]->display();
95 } 95 }
96 96
97 RootWindowController* WmTestBase::GetPrimaryRootWindowController() {
98 std::vector<RootWindowController*> roots =
99 test_helper_->GetRootsOrderedByDisplayId();
100 DCHECK(!roots.empty());
101 return roots[0];
102 }
103
104 RootWindowController* WmTestBase::GetSecondaryRootWindowController() {
105 std::vector<RootWindowController*> roots =
106 test_helper_->GetRootsOrderedByDisplayId();
107 return roots.size() < 2 ? nullptr : roots[1];
108 }
109
97 ui::Window* WmTestBase::CreateTestWindow(const gfx::Rect& bounds) { 110 ui::Window* WmTestBase::CreateTestWindow(const gfx::Rect& bounds) {
98 return CreateTestWindow(bounds, ui::wm::WINDOW_TYPE_NORMAL); 111 return CreateTestWindow(bounds, ui::wm::WINDOW_TYPE_NORMAL);
99 } 112 }
100 113
101 ui::Window* WmTestBase::CreateTestWindow(const gfx::Rect& bounds, 114 ui::Window* WmTestBase::CreateTestWindow(const gfx::Rect& bounds,
102 ui::wm::WindowType window_type) { 115 ui::wm::WindowType window_type) {
103 std::map<std::string, std::vector<uint8_t>> properties; 116 std::map<std::string, std::vector<uint8_t>> properties;
104 properties[ui::mojom::WindowManager::kWindowType_Property] = 117 properties[ui::mojom::WindowManager::kWindowType_Property] =
105 mojo::ConvertTo<std::vector<uint8_t>>( 118 mojo::ConvertTo<std::vector<uint8_t>>(
106 static_cast<int32_t>(MusWindowTypeFromWmWindowType(window_type))); 119 static_cast<int32_t>(MusWindowTypeFromWmWindowType(window_type)));
(...skipping 21 matching lines...) Expand all
128 properties[ui::mojom::WindowManager::kShowState_Property] = 141 properties[ui::mojom::WindowManager::kShowState_Property] =
129 mojo::ConvertTo<std::vector<uint8_t>>( 142 mojo::ConvertTo<std::vector<uint8_t>>(
130 static_cast<int32_t>(ui::mojom::ShowState::FULLSCREEN)); 143 static_cast<int32_t>(ui::mojom::ShowState::FULLSCREEN));
131 ui::Window* window = test_helper_->GetRootsOrderedByDisplayId()[0] 144 ui::Window* window = test_helper_->GetRootsOrderedByDisplayId()[0]
132 ->window_manager() 145 ->window_manager()
133 ->NewTopLevelWindow(&properties); 146 ->NewTopLevelWindow(&properties);
134 window->SetVisible(true); 147 window->SetVisible(true);
135 return window; 148 return window;
136 } 149 }
137 150
151 ui::Window* WmTestBase::CreateFullscreenTestWindow(RootWindowController* root) {
152 std::map<std::string, std::vector<uint8_t>> properties;
153 properties[ui::mojom::WindowManager::kShowState_Property] =
154 mojo::ConvertTo<std::vector<uint8_t>>(
155 static_cast<int32_t>(ui::mojom::ShowState::FULLSCREEN));
156 properties[ui::mojom::WindowManager::kInitialDisplayId_Property] =
157 mojo::ConvertTo<std::vector<uint8_t>>(root->display().id());
158
159 ui::Window* window = root->window_manager()->NewTopLevelWindow(&properties);
160 window->SetVisible(true);
161 return window;
162 }
163
138 ui::Window* WmTestBase::CreateChildTestWindow(ui::Window* parent, 164 ui::Window* WmTestBase::CreateChildTestWindow(ui::Window* parent,
139 const gfx::Rect& bounds) { 165 const gfx::Rect& bounds) {
140 std::map<std::string, std::vector<uint8_t>> properties; 166 std::map<std::string, std::vector<uint8_t>> properties;
141 properties[ui::mojom::WindowManager::kWindowType_Property] = 167 properties[ui::mojom::WindowManager::kWindowType_Property] =
142 mojo::ConvertTo<std::vector<uint8_t>>(static_cast<int32_t>( 168 mojo::ConvertTo<std::vector<uint8_t>>(static_cast<int32_t>(
143 MusWindowTypeFromWmWindowType(ui::wm::WINDOW_TYPE_NORMAL))); 169 MusWindowTypeFromWmWindowType(ui::wm::WINDOW_TYPE_NORMAL)));
144 ui::Window* window = test_helper_->GetRootsOrderedByDisplayId()[0] 170 ui::Window* window = test_helper_->GetRootsOrderedByDisplayId()[0]
145 ->root() 171 ->root()
146 ->window_tree() 172 ->window_tree()
147 ->NewWindow(&properties); 173 ->NewWindow(&properties);
148 window->SetBounds(bounds); 174 window->SetBounds(bounds);
149 window->SetVisible(true); 175 window->SetVisible(true);
150 parent->AddChild(window); 176 parent->AddChild(window);
151 return window; 177 return window;
152 } 178 }
153 179
154 void WmTestBase::SetUp() { 180 void WmTestBase::SetUp() {
155 setup_called_ = true; 181 setup_called_ = true;
156 test_helper_.reset(new WmTestHelper); 182 test_helper_.reset(new WmTestHelper);
157 test_helper_->Init(); 183 test_helper_->Init();
158 } 184 }
159 185
160 void WmTestBase::TearDown() { 186 void WmTestBase::TearDown() {
161 teardown_called_ = true; 187 teardown_called_ = true;
162 test_helper_.reset(); 188 test_helper_.reset();
163 } 189 }
164 190
165 } // namespace mus 191 } // namespace mus
166 } // namespace ash 192 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698