| 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/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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 ui::Window* window = test_helper_->GetRootsOrderedByDisplayId()[0] | 117 ui::Window* window = test_helper_->GetRootsOrderedByDisplayId()[0] |
| 118 ->window_manager() | 118 ->window_manager() |
| 119 ->NewTopLevelWindow(&properties); | 119 ->NewTopLevelWindow(&properties); |
| 120 window->SetVisible(true); | 120 window->SetVisible(true); |
| 121 // Most tests expect a minimum size of 0x0. | 121 // Most tests expect a minimum size of 0x0. |
| 122 WmWindowMusTestApi(WmWindowMus::Get(window)).set_use_empty_minimum_size(true); | 122 WmWindowMusTestApi(WmWindowMus::Get(window)).set_use_empty_minimum_size(true); |
| 123 return window; | 123 return window; |
| 124 } | 124 } |
| 125 | 125 |
| 126 RootWindowController* WmTestBase::GetPrimaryRootWindowController() { |
| 127 std::vector<RootWindowController*> roots = |
| 128 test_helper_->GetRootsOrderedByDisplayId(); |
| 129 DCHECK(!roots.empty()); |
| 130 return roots[0]; |
| 131 } |
| 132 |
| 133 RootWindowController* WmTestBase::GetSecondaryRootWindowController() { |
| 134 std::vector<RootWindowController*> roots = |
| 135 test_helper_->GetRootsOrderedByDisplayId(); |
| 136 return roots.size() < 2 ? nullptr : roots[1]; |
| 137 } |
| 138 |
| 139 ui::Window* WmTestBase::CreateTestWindow(const gfx::Rect& bounds, |
| 140 ui::wm::WindowType window_type, |
| 141 RootWindowController* root) { |
| 142 std::map<std::string, std::vector<uint8_t>> properties; |
| 143 properties[ui::mojom::WindowManager::kWindowType_Property] = |
| 144 mojo::ConvertTo<std::vector<uint8_t>>( |
| 145 static_cast<int32_t>(MusWindowTypeFromWmWindowType(window_type))); |
| 146 if (!bounds.IsEmpty()) { |
| 147 properties[ui::mojom::WindowManager::kInitialBounds_Property] = |
| 148 mojo::ConvertTo<std::vector<uint8_t>>(bounds); |
| 149 } |
| 150 properties[ui::mojom::WindowManager::kResizeBehavior_Property] = |
| 151 mojo::ConvertTo<std::vector<uint8_t>>( |
| 152 ui::mojom::kResizeBehaviorCanResize | |
| 153 ui::mojom::kResizeBehaviorCanMaximize | |
| 154 ui::mojom::kResizeBehaviorCanMinimize); |
| 155 |
| 156 properties[ui::mojom::WindowManager::kInitialDisplayId_Property] = |
| 157 mojo::ConvertTo<std::vector<uint8_t>>(root->display().id()); |
| 158 // LOG(ERROR) << "\n WmTestBase::CreateTestWindow |
| 159 // properties[ui::mojom::WindowManager::kInitialDisplayId_Property]=" << |
| 160 // mojo::TypeConverter<int64_t, |
| 161 // std::vector<uint8_t>>::Convert(properties[ui::mojom::WindowManager::kInitia
lDisplayId_Property]); |
| 162 |
| 163 LOG(ERROR) << "\n root->display().id()" << root->display().id() << "\n"; |
| 164 |
| 165 ui::Window* window = root->window_manager()->NewTopLevelWindow(&properties); |
| 166 window->SetVisible(true); |
| 167 // Most tests expect a minimum size of 0x0. |
| 168 WmWindowMusTestApi(WmWindowMus::Get(window)).set_use_empty_minimum_size(true); |
| 169 return window; |
| 170 } |
| 171 |
| 172 ui::Window* WmTestBase::CreateFullscreenTestWindow(RootWindowController* root) { |
| 173 std::map<std::string, std::vector<uint8_t>> properties; |
| 174 properties[ui::mojom::WindowManager::kShowState_Property] = |
| 175 mojo::ConvertTo<std::vector<uint8_t>>( |
| 176 static_cast<int32_t>(ui::mojom::ShowState::FULLSCREEN)); |
| 177 properties[ui::mojom::WindowManager::kInitialDisplayId_Property] = |
| 178 mojo::ConvertTo<std::vector<uint8_t>>(root->display().id()); |
| 179 |
| 180 ui::Window* window = root->window_manager()->NewTopLevelWindow(&properties); |
| 181 window->SetVisible(true); |
| 182 return window; |
| 183 } |
| 184 |
| 126 ui::Window* WmTestBase::CreateFullscreenTestWindow() { | 185 ui::Window* WmTestBase::CreateFullscreenTestWindow() { |
| 127 std::map<std::string, std::vector<uint8_t>> properties; | 186 std::map<std::string, std::vector<uint8_t>> properties; |
| 128 properties[ui::mojom::WindowManager::kShowState_Property] = | 187 properties[ui::mojom::WindowManager::kShowState_Property] = |
| 129 mojo::ConvertTo<std::vector<uint8_t>>( | 188 mojo::ConvertTo<std::vector<uint8_t>>( |
| 130 static_cast<int32_t>(ui::mojom::ShowState::FULLSCREEN)); | 189 static_cast<int32_t>(ui::mojom::ShowState::FULLSCREEN)); |
| 131 ui::Window* window = test_helper_->GetRootsOrderedByDisplayId()[0] | 190 ui::Window* window = test_helper_->GetRootsOrderedByDisplayId()[0] |
| 132 ->window_manager() | 191 ->window_manager() |
| 133 ->NewTopLevelWindow(&properties); | 192 ->NewTopLevelWindow(&properties); |
| 134 window->SetVisible(true); | 193 window->SetVisible(true); |
| 135 return window; | 194 return window; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 157 test_helper_->Init(); | 216 test_helper_->Init(); |
| 158 } | 217 } |
| 159 | 218 |
| 160 void WmTestBase::TearDown() { | 219 void WmTestBase::TearDown() { |
| 161 teardown_called_ = true; | 220 teardown_called_ = true; |
| 162 test_helper_.reset(); | 221 test_helper_.reset(); |
| 163 } | 222 } |
| 164 | 223 |
| 165 } // namespace mus | 224 } // namespace mus |
| 166 } // namespace ash | 225 } // namespace ash |
| OLD | NEW |