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]; | |
|
mfomitchev
2016/11/18 17:36:24
The current code doesn't seem to account for the p
thanhph
2016/11/18 19:15:44
I get this idea from the function ui::Window* WmTe
| |
| 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 Loading... | |
| 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) { | |
|
mfomitchev
2016/11/18 17:36:24
Avoid duplicate code between this and the above me
thanhph
2016/11/18 19:15:44
I merged the codes in 2 functions. Thanks!
| |
| 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 // properties[ui::mojom::WindowManager::kInitialContainerId_Property] = | |
|
mfomitchev
2016/11/18 17:36:24
remove
thanhph
2016/11/18 19:15:44
Done.
| |
| 160 // mojo::ConvertTo<std::vector<uint8_t>>(root->display().id()); | |
| 161 | |
| 162 ui::Window* window = root->window_manager()->NewTopLevelWindow(&properties); | |
| 163 window->SetVisible(true); | |
| 164 return window; | |
| 165 } | |
| 166 | |
| 138 ui::Window* WmTestBase::CreateChildTestWindow(ui::Window* parent, | 167 ui::Window* WmTestBase::CreateChildTestWindow(ui::Window* parent, |
| 139 const gfx::Rect& bounds) { | 168 const gfx::Rect& bounds) { |
| 140 std::map<std::string, std::vector<uint8_t>> properties; | 169 std::map<std::string, std::vector<uint8_t>> properties; |
| 141 properties[ui::mojom::WindowManager::kWindowType_Property] = | 170 properties[ui::mojom::WindowManager::kWindowType_Property] = |
| 142 mojo::ConvertTo<std::vector<uint8_t>>(static_cast<int32_t>( | 171 mojo::ConvertTo<std::vector<uint8_t>>(static_cast<int32_t>( |
| 143 MusWindowTypeFromWmWindowType(ui::wm::WINDOW_TYPE_NORMAL))); | 172 MusWindowTypeFromWmWindowType(ui::wm::WINDOW_TYPE_NORMAL))); |
| 144 ui::Window* window = test_helper_->GetRootsOrderedByDisplayId()[0] | 173 ui::Window* window = test_helper_->GetRootsOrderedByDisplayId()[0] |
| 145 ->root() | 174 ->root() |
| 146 ->window_tree() | 175 ->window_tree() |
| 147 ->NewWindow(&properties); | 176 ->NewWindow(&properties); |
| 148 window->SetBounds(bounds); | 177 window->SetBounds(bounds); |
| 149 window->SetVisible(true); | 178 window->SetVisible(true); |
| 150 parent->AddChild(window); | 179 parent->AddChild(window); |
| 151 return window; | 180 return window; |
| 152 } | 181 } |
| 153 | 182 |
| 154 void WmTestBase::SetUp() { | 183 void WmTestBase::SetUp() { |
| 155 setup_called_ = true; | 184 setup_called_ = true; |
| 156 test_helper_.reset(new WmTestHelper); | 185 test_helper_.reset(new WmTestHelper); |
| 157 test_helper_->Init(); | 186 test_helper_->Init(); |
| 158 } | 187 } |
| 159 | 188 |
| 160 void WmTestBase::TearDown() { | 189 void WmTestBase::TearDown() { |
| 161 teardown_called_ = true; | 190 teardown_called_ = true; |
| 162 test_helper_.reset(); | 191 test_helper_.reset(); |
| 163 } | 192 } |
| 164 | 193 |
| 165 } // namespace mus | 194 } // namespace mus |
| 166 } // namespace ash | 195 } // namespace ash |
| OLD | NEW |