Chromium Code Reviews| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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))); |
| 107 if (!bounds.IsEmpty()) { | 120 if (!bounds.IsEmpty()) { |
| 108 properties[ui::mojom::WindowManager::kInitialBounds_Property] = | 121 properties[ui::mojom::WindowManager::kInitialBounds_Property] = |
| 109 mojo::ConvertTo<std::vector<uint8_t>>(bounds); | 122 mojo::ConvertTo<std::vector<uint8_t>>(bounds); |
| 110 } | 123 } |
| 111 properties[ui::mojom::WindowManager::kResizeBehavior_Property] = | 124 properties[ui::mojom::WindowManager::kResizeBehavior_Property] = |
| 112 mojo::ConvertTo<std::vector<uint8_t>>( | 125 mojo::ConvertTo<std::vector<uint8_t>>( |
| 113 ui::mojom::kResizeBehaviorCanResize | | 126 ui::mojom::kResizeBehaviorCanResize | |
| 114 ui::mojom::kResizeBehaviorCanMaximize | | 127 ui::mojom::kResizeBehaviorCanMaximize | |
| 115 ui::mojom::kResizeBehaviorCanMinimize); | 128 ui::mojom::kResizeBehaviorCanMinimize); |
| 116 | 129 |
| 117 ui::Window* window = test_helper_->GetRootsOrderedByDisplayId()[0] | 130 ui::Window* window = test_helper_->GetRootsOrderedByDisplayId()[0] |
| 118 ->window_manager() | 131 ->window_manager() |
| 119 ->NewTopLevelWindow(&properties); | 132 ->NewTopLevelWindow(&properties); |
| 120 window->SetVisible(true); | 133 window->SetVisible(true); |
| 121 // Most tests expect a minimum size of 0x0. | 134 // Most tests expect a minimum size of 0x0. |
| 122 WmWindowMusTestApi(WmWindowMus::Get(window)).set_use_empty_minimum_size(true); | 135 WmWindowMusTestApi(WmWindowMus::Get(window)).set_use_empty_minimum_size(true); |
| 123 return window; | 136 return window; |
| 124 } | 137 } |
| 125 | 138 |
| 126 ui::Window* WmTestBase::CreateFullscreenTestWindow() { | 139 ui::Window* WmTestBase::CreateFullscreenTestWindow( |
| 140 RootWindowController* root = nullptr) { | |
| 127 std::map<std::string, std::vector<uint8_t>> properties; | 141 std::map<std::string, std::vector<uint8_t>> properties; |
| 128 properties[ui::mojom::WindowManager::kShowState_Property] = | 142 properties[ui::mojom::WindowManager::kShowState_Property] = |
| 129 mojo::ConvertTo<std::vector<uint8_t>>( | 143 mojo::ConvertTo<std::vector<uint8_t>>( |
| 130 static_cast<int32_t>(ui::mojom::ShowState::FULLSCREEN)); | 144 static_cast<int32_t>(ui::mojom::ShowState::FULLSCREEN)); |
| 131 ui::Window* window = test_helper_->GetRootsOrderedByDisplayId()[0] | 145 |
| 132 ->window_manager() | 146 ui::Window* window = nullptr; |
| 133 ->NewTopLevelWindow(&properties); | 147 if (root) { |
| 148 properties[ui::mojom::WindowManager::kInitialDisplayId_Property] = | |
| 149 mojo::ConvertTo<std::vector<uint8_t>>(root->display().id()); | |
| 150 window = root->window_manager()->NewTopLevelWindow(&properties); | |
|
mfomitchev
2016/11/18 20:35:58
I think window manager is the same for all root wi
thanhph
2016/11/18 20:53:08
Great stuff here Mikhail, thanks! The WM is the sa
| |
| 151 } else | |
| 152 window = test_helper_->GetRootsOrderedByDisplayId()[0] | |
| 153 ->window_manager() | |
| 154 ->NewTopLevelWindow(&properties); | |
| 134 window->SetVisible(true); | 155 window->SetVisible(true); |
| 135 return window; | 156 return window; |
| 136 } | 157 } |
| 137 | 158 |
| 138 ui::Window* WmTestBase::CreateChildTestWindow(ui::Window* parent, | 159 ui::Window* WmTestBase::CreateChildTestWindow(ui::Window* parent, |
| 139 const gfx::Rect& bounds) { | 160 const gfx::Rect& bounds) { |
| 140 std::map<std::string, std::vector<uint8_t>> properties; | 161 std::map<std::string, std::vector<uint8_t>> properties; |
| 141 properties[ui::mojom::WindowManager::kWindowType_Property] = | 162 properties[ui::mojom::WindowManager::kWindowType_Property] = |
| 142 mojo::ConvertTo<std::vector<uint8_t>>(static_cast<int32_t>( | 163 mojo::ConvertTo<std::vector<uint8_t>>(static_cast<int32_t>( |
| 143 MusWindowTypeFromWmWindowType(ui::wm::WINDOW_TYPE_NORMAL))); | 164 MusWindowTypeFromWmWindowType(ui::wm::WINDOW_TYPE_NORMAL))); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 157 test_helper_->Init(); | 178 test_helper_->Init(); |
| 158 } | 179 } |
| 159 | 180 |
| 160 void WmTestBase::TearDown() { | 181 void WmTestBase::TearDown() { |
| 161 teardown_called_ = true; | 182 teardown_called_ = true; |
| 162 test_helper_.reset(); | 183 test_helper_.reset(); |
| 163 } | 184 } |
| 164 | 185 |
| 165 } // namespace mus | 186 } // namespace mus |
| 166 } // namespace ash | 187 } // namespace ash |
| OLD | NEW |