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

Side by Side Diff: services/ui/test_wm/test_wm.cc

Issue 2535983004: Makes sure bounds and visibilty are updated correctly for new displays (Closed)
Patch Set: merge Created 4 years 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
« no previous file with comments | « services/ui/test_wm/BUILD.gn ('k') | ui/aura/mus/window_tree_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <memory> 5 #include <memory>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "mojo/public/cpp/bindings/binding.h" 10 #include "mojo/public/cpp/bindings/binding.h"
11 #include "services/service_manager/public/c/main.h" 11 #include "services/service_manager/public/c/main.h"
12 #include "services/service_manager/public/cpp/connector.h" 12 #include "services/service_manager/public/cpp/connector.h"
13 #include "services/service_manager/public/cpp/service.h" 13 #include "services/service_manager/public/cpp/service.h"
14 #include "services/service_manager/public/cpp/service_context.h" 14 #include "services/service_manager/public/cpp/service_context.h"
15 #include "services/service_manager/public/cpp/service_runner.h" 15 #include "services/service_manager/public/cpp/service_runner.h"
16 #include "services/ui/public/cpp/gpu/gpu_service.h" 16 #include "services/ui/public/cpp/gpu/gpu_service.h"
17 #include "ui/aura/env.h" 17 #include "ui/aura/env.h"
18 #include "ui/aura/mus/mus_context_factory.h" 18 #include "ui/aura/mus/mus_context_factory.h"
19 #include "ui/aura/mus/property_converter.h" 19 #include "ui/aura/mus/property_converter.h"
20 #include "ui/aura/mus/property_utils.h" 20 #include "ui/aura/mus/property_utils.h"
21 #include "ui/aura/mus/window_manager_delegate.h" 21 #include "ui/aura/mus/window_manager_delegate.h"
22 #include "ui/aura/mus/window_tree_client.h" 22 #include "ui/aura/mus/window_tree_client.h"
23 #include "ui/aura/mus/window_tree_client_delegate.h" 23 #include "ui/aura/mus/window_tree_client_delegate.h"
24 #include "ui/aura/mus/window_tree_host_mus.h" 24 #include "ui/aura/mus/window_tree_host_mus.h"
25 #include "ui/aura/test/test_focus_client.h" 25 #include "ui/aura/test/test_focus_client.h"
26 #include "ui/aura/window.h" 26 #include "ui/aura/window.h"
27 #include "ui/display/display.h" 27 #include "ui/display/display.h"
28 #include "ui/display/test/test_screen.h" 28 #include "ui/display/display_list.h"
29 #include "ui/display/screen_base.h"
29 #include "ui/wm/core/capture_controller.h" 30 #include "ui/wm/core/capture_controller.h"
30 #include "ui/wm/core/wm_state.h" 31 #include "ui/wm/core/wm_state.h"
31 32
32 namespace ui { 33 namespace ui {
33 namespace test { 34 namespace test {
34 35
35 class TestWM : public service_manager::Service, 36 class TestWM : public service_manager::Service,
36 public aura::WindowTreeClientDelegate, 37 public aura::WindowTreeClientDelegate,
37 public aura::WindowManagerDelegate { 38 public aura::WindowManagerDelegate {
38 public: 39 public:
39 TestWM() {} 40 TestWM() {}
40 41
41 ~TestWM() override { 42 ~TestWM() override {
42 // WindowTreeHost uses state from WindowTreeClient, so destroy it first. 43 // WindowTreeHost uses state from WindowTreeClient, so destroy it first.
43 window_tree_host_.reset(); 44 window_tree_host_.reset();
44 45
45 // WindowTreeClient destruction may callback to us. 46 // WindowTreeClient destruction may callback to us.
46 window_tree_client_.reset(); 47 window_tree_client_.reset();
47 48
48 gpu_service_.reset(); 49 gpu_service_.reset();
49 50
50 display::Screen::SetScreenInstance(nullptr); 51 display::Screen::SetScreenInstance(nullptr);
51 } 52 }
52 53
53 private: 54 private:
54 // service_manager::Service: 55 // service_manager::Service:
55 void OnStart() override { 56 void OnStart() override {
56 CHECK(!started_); 57 CHECK(!started_);
57 started_ = true; 58 started_ = true;
58 test_screen_ = base::MakeUnique<display::test::TestScreen>(); 59 screen_ = base::MakeUnique<display::ScreenBase>();
59 display::Screen::SetScreenInstance(test_screen_.get()); 60 display::Screen::SetScreenInstance(screen_.get());
60 aura_env_ = aura::Env::CreateInstance(aura::Env::Mode::MUS); 61 aura_env_ = aura::Env::CreateInstance(aura::Env::Mode::MUS);
61 gpu_service_ = ui::GpuService::Create(context()->connector(), nullptr); 62 gpu_service_ = ui::GpuService::Create(context()->connector(), nullptr);
62 compositor_context_factory_ = 63 compositor_context_factory_ =
63 base::MakeUnique<aura::MusContextFactory>(gpu_service_.get()); 64 base::MakeUnique<aura::MusContextFactory>(gpu_service_.get());
64 aura_env_->set_context_factory(compositor_context_factory_.get()); 65 aura_env_->set_context_factory(compositor_context_factory_.get());
65 window_tree_client_ = base::MakeUnique<aura::WindowTreeClient>( 66 window_tree_client_ = base::MakeUnique<aura::WindowTreeClient>(
66 context()->connector(), this, this); 67 context()->connector(), this, this);
67 aura_env_->SetWindowTreeClient(window_tree_client_.get()); 68 aura_env_->SetWindowTreeClient(window_tree_client_.get());
68 window_tree_client_->ConnectAsWindowManager(); 69 window_tree_client_->ConnectAsWindowManager();
69 } 70 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 SetWindowType(window, window_type); 121 SetWindowType(window, window_type);
121 window->Init(LAYER_NOT_DRAWN); 122 window->Init(LAYER_NOT_DRAWN);
122 window->SetBounds(gfx::Rect(10, 10, 500, 500)); 123 window->SetBounds(gfx::Rect(10, 10, 500, 500));
123 root_->AddChild(window); 124 root_->AddChild(window);
124 return window; 125 return window;
125 } 126 }
126 void OnWmClientJankinessChanged(const std::set<aura::Window*>& client_windows, 127 void OnWmClientJankinessChanged(const std::set<aura::Window*>& client_windows,
127 bool janky) override { 128 bool janky) override {
128 // Don't care. 129 // Don't care.
129 } 130 }
130 void OnWmWillCreateDisplay(const display::Display& display) override {} 131 void OnWmWillCreateDisplay(const display::Display& display) override {
132 // This class only deals with one display.
133 DCHECK_EQ(0u, screen_->display_list().displays().size());
134 screen_->display_list().AddDisplay(display,
135 display::DisplayList::Type::PRIMARY);
136 }
131 void OnWmNewDisplay(std::unique_ptr<aura::WindowTreeHostMus> window_tree_host, 137 void OnWmNewDisplay(std::unique_ptr<aura::WindowTreeHostMus> window_tree_host,
132 const display::Display& display) override { 138 const display::Display& display) override {
133 // Only handles a single root. 139 // Only handles a single root.
134 DCHECK(!root_); 140 DCHECK(!root_);
135 window_tree_host_ = std::move(window_tree_host); 141 window_tree_host_ = std::move(window_tree_host);
136 root_ = window_tree_host_->window(); 142 root_ = window_tree_host_->window();
137 DCHECK(window_manager_client_); 143 DCHECK(window_manager_client_);
138 window_manager_client_->AddActivationParent(root_); 144 window_manager_client_->AddActivationParent(root_);
139 ui::mojom::FrameDecorationValuesPtr frame_decoration_values = 145 ui::mojom::FrameDecorationValuesPtr frame_decoration_values =
140 ui::mojom::FrameDecorationValues::New(); 146 ui::mojom::FrameDecorationValues::New();
(...skipping 13 matching lines...) Expand all
154 const gfx::Point& cursor_location, 160 const gfx::Point& cursor_location,
155 const base::Callback<void(bool)>& on_done) override { 161 const base::Callback<void(bool)>& on_done) override {
156 // Don't care. 162 // Don't care.
157 } 163 }
158 void OnWmCancelMoveLoop(aura::Window* window) override {} 164 void OnWmCancelMoveLoop(aura::Window* window) override {}
159 void OnWmSetClientArea( 165 void OnWmSetClientArea(
160 aura::Window* window, 166 aura::Window* window,
161 const gfx::Insets& insets, 167 const gfx::Insets& insets,
162 const std::vector<gfx::Rect>& additional_client_areas) override {} 168 const std::vector<gfx::Rect>& additional_client_areas) override {}
163 169
164 // Dummy screen required to be the screen instance. 170 std::unique_ptr<display::ScreenBase> screen_;
165 std::unique_ptr<display::test::TestScreen> test_screen_;
166 171
167 std::unique_ptr<aura::Env> aura_env_; 172 std::unique_ptr<aura::Env> aura_env_;
168 ::wm::WMState wm_state_; 173 ::wm::WMState wm_state_;
169 aura::PropertyConverter property_converter_; 174 aura::PropertyConverter property_converter_;
170 aura::test::TestFocusClient focus_client_; 175 aura::test::TestFocusClient focus_client_;
171 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host_; 176 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host_;
172 aura::Window* root_ = nullptr; 177 aura::Window* root_ = nullptr;
173 aura::WindowManagerClient* window_manager_client_ = nullptr; 178 aura::WindowManagerClient* window_manager_client_ = nullptr;
174 std::unique_ptr<aura::WindowTreeClient> window_tree_client_; 179 std::unique_ptr<aura::WindowTreeClient> window_tree_client_;
175 std::unique_ptr<ui::GpuService> gpu_service_; 180 std::unique_ptr<ui::GpuService> gpu_service_;
176 std::unique_ptr<aura::MusContextFactory> compositor_context_factory_; 181 std::unique_ptr<aura::MusContextFactory> compositor_context_factory_;
177 182
178 bool started_ = false; 183 bool started_ = false;
179 184
180 DISALLOW_COPY_AND_ASSIGN(TestWM); 185 DISALLOW_COPY_AND_ASSIGN(TestWM);
181 }; 186 };
182 187
183 } // namespace test 188 } // namespace test
184 } // namespace ui 189 } // namespace ui
185 190
186 MojoResult ServiceMain(MojoHandle service_request_handle) { 191 MojoResult ServiceMain(MojoHandle service_request_handle) {
187 service_manager::ServiceRunner runner(new ui::test::TestWM); 192 service_manager::ServiceRunner runner(new ui::test::TestWM);
188 return runner.Run(service_request_handle); 193 return runner.Run(service_request_handle);
189 } 194 }
OLDNEW
« no previous file with comments | « services/ui/test_wm/BUILD.gn ('k') | ui/aura/mus/window_tree_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698