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

Side by Side Diff: ui/ozone/platform/wayland/fake_server.h

Issue 2042503002: ozone/platform/wayland: Add support for wl_output_interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove WaylandDisplay::instance Created 4 years, 6 months 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 #ifndef UI_OZONE_PLATFORM_WAYLAND_FAKE_SERVER_H_ 5 #ifndef UI_OZONE_PLATFORM_WAYLAND_FAKE_SERVER_H_
6 #define UI_OZONE_PLATFORM_WAYLAND_FAKE_SERVER_H_ 6 #define UI_OZONE_PLATFORM_WAYLAND_FAKE_SERVER_H_
7 7
8 #include <wayland-server-core.h> 8 #include <wayland-server-core.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/message_loop/message_pump_libevent.h" 11 #include "base/message_loop/message_pump_libevent.h"
12 #include "base/synchronization/waitable_event.h" 12 #include "base/synchronization/waitable_event.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "ui/display/display.h"
15 16
16 struct wl_client; 17 struct wl_client;
17 struct wl_display; 18 struct wl_display;
18 struct wl_event_loop; 19 struct wl_event_loop;
19 struct wl_global; 20 struct wl_global;
20 struct wl_resource; 21 struct wl_resource;
21 22
22 namespace wl { 23 namespace wl {
23 24
24 class ServerObject { 25 class ServerObject {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 ~MockCompositor() override; 121 ~MockCompositor() override;
121 122
122 void AddSurface(std::unique_ptr<MockSurface> surface); 123 void AddSurface(std::unique_ptr<MockSurface> surface);
123 124
124 private: 125 private:
125 std::vector<std::unique_ptr<MockSurface>> surfaces_; 126 std::vector<std::unique_ptr<MockSurface>> surfaces_;
126 127
127 DISALLOW_COPY_AND_ASSIGN(MockCompositor); 128 DISALLOW_COPY_AND_ASSIGN(MockCompositor);
128 }; 129 };
129 130
131 class MockOutput : public Global {
132 public:
133 MockOutput();
134 ~MockOutput() override;
135 void SetDisplay(const display::Display& display) { fake_display_ = display; }
136 const display::Display& Display() { return fake_display_; }
137
138 private:
139 display::Display fake_display_;
140
141 DISALLOW_COPY_AND_ASSIGN(MockOutput);
142 };
143
130 class MockSeat : public Global { 144 class MockSeat : public Global {
131 public: 145 public:
132 MockSeat(); 146 MockSeat();
133 ~MockSeat() override; 147 ~MockSeat() override;
134 148
135 std::unique_ptr<MockPointer> pointer; 149 std::unique_ptr<MockPointer> pointer;
136 150
137 private: 151 private:
138 DISALLOW_COPY_AND_ASSIGN(MockSeat); 152 DISALLOW_COPY_AND_ASSIGN(MockSeat);
139 }; 153 };
(...skipping 25 matching lines...) Expand all
165 // ensuring that this file descriptor gets closed (for example, by calling 179 // ensuring that this file descriptor gets closed (for example, by calling
166 // wl_display_connect). 180 // wl_display_connect).
167 bool Start(); 181 bool Start();
168 182
169 // Pause the server when it becomes idle. 183 // Pause the server when it becomes idle.
170 void Pause(); 184 void Pause();
171 185
172 // Resume the server after flushing client connections. 186 // Resume the server after flushing client connections.
173 void Resume(); 187 void Resume();
174 188
189 void AddDisplay(const display::Display&);
190
175 template <typename T> 191 template <typename T>
176 T* GetObject(uint32_t id) { 192 T* GetObject(uint32_t id) {
177 wl_resource* resource = wl_client_get_object(client_, id); 193 wl_resource* resource = wl_client_get_object(client_, id);
178 return resource ? T::FromResource(resource) : nullptr; 194 return resource ? T::FromResource(resource) : nullptr;
179 } 195 }
180 196
181 MockSeat* seat() { return &seat_; } 197 MockSeat* seat() { return &seat_; }
182 MockXdgShell* xdg_shell() { return &xdg_shell_; } 198 MockXdgShell* xdg_shell() { return &xdg_shell_; }
183 199
184 private: 200 private:
185 void DoPause(); 201 void DoPause();
186 202
187 std::unique_ptr<base::MessagePump> CreateMessagePump(); 203 std::unique_ptr<base::MessagePump> CreateMessagePump();
188 204
189 // base::MessagePumpLibevent::Watcher 205 // base::MessagePumpLibevent::Watcher
190 void OnFileCanReadWithoutBlocking(int fd) override; 206 void OnFileCanReadWithoutBlocking(int fd) override;
191 void OnFileCanWriteWithoutBlocking(int fd) override; 207 void OnFileCanWriteWithoutBlocking(int fd) override;
192 208
193 std::unique_ptr<wl_display, DisplayDeleter> display_; 209 std::unique_ptr<wl_display, DisplayDeleter> display_;
194 wl_client* client_ = nullptr; 210 wl_client* client_ = nullptr;
195 wl_event_loop* event_loop_ = nullptr; 211 wl_event_loop* event_loop_ = nullptr;
196 212
197 base::WaitableEvent pause_event_; 213 base::WaitableEvent pause_event_;
198 base::WaitableEvent resume_event_; 214 base::WaitableEvent resume_event_;
199 bool paused_ = false; 215 bool paused_ = false;
200 216
201 MockCompositor compositor_; 217 MockCompositor compositor_;
218 MockOutput output_;
202 MockSeat seat_; 219 MockSeat seat_;
203 MockXdgShell xdg_shell_; 220 MockXdgShell xdg_shell_;
204 221
205 base::MessagePumpLibevent::FileDescriptorWatcher controller_; 222 base::MessagePumpLibevent::FileDescriptorWatcher controller_;
206 223
207 DISALLOW_COPY_AND_ASSIGN(FakeServer); 224 DISALLOW_COPY_AND_ASSIGN(FakeServer);
208 }; 225 };
209 226
210 } // namespace wl 227 } // namespace wl
211 228
212 #endif // UI_OZONE_PLATFORM_WAYLAND_FAKE_SERVER_H_ 229 #endif // UI_OZONE_PLATFORM_WAYLAND_FAKE_SERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698