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

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: WaylandDisplay => WaylandConnection, WaylandScreen => WaylandOutput 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"
rjkroege 2016/07/08 21:59:19 What is this file for? Can you add a class comment
joone 2016/07/20 00:07:20 I removed display::Display dependency.
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 }; 86 };
86 87
87 class Global { 88 class Global {
88 public: 89 public:
89 Global(const wl_interface* interface, 90 Global(const wl_interface* interface,
90 const void* implementation, 91 const void* implementation,
91 uint32_t version); 92 uint32_t version);
92 virtual ~Global(); 93 virtual ~Global();
93 94
94 bool Initialize(wl_display* display); 95 bool Initialize(wl_display* display);
96 virtual void OnBind() {}
95 97
96 // The first bound resource to this global, which is usually all that is 98 // The first bound resource to this global, which is usually all that is
97 // useful when testing a simple client. 99 // useful when testing a simple client.
98 wl_resource* resource() { return resource_; } 100 wl_resource* resource() { return resource_; }
99 101
100 static void Bind(wl_client* client, 102 static void Bind(wl_client* client,
101 void* data, 103 void* data,
102 uint32_t version, 104 uint32_t version,
103 uint32_t id); 105 uint32_t id);
104 static void OnResourceDestroyed(wl_resource* resource); 106 static void OnResourceDestroyed(wl_resource* resource);
(...skipping 15 matching lines...) Expand all
120 ~MockCompositor() override; 122 ~MockCompositor() override;
121 123
122 void AddSurface(std::unique_ptr<MockSurface> surface); 124 void AddSurface(std::unique_ptr<MockSurface> surface);
123 125
124 private: 126 private:
125 std::vector<std::unique_ptr<MockSurface>> surfaces_; 127 std::vector<std::unique_ptr<MockSurface>> surfaces_;
126 128
127 DISALLOW_COPY_AND_ASSIGN(MockCompositor); 129 DISALLOW_COPY_AND_ASSIGN(MockCompositor);
128 }; 130 };
129 131
132 class MockOutput : public Global {
133 public:
134 MockOutput();
135 ~MockOutput() override;
136 void SetDisplay(const display::Display& display) { fake_display_ = display; }
137 const display::Display& Display() { return fake_display_; }
138 void OnBind() override;
139
140 private:
141 display::Display fake_display_;
142
143 DISALLOW_COPY_AND_ASSIGN(MockOutput);
144 };
145
130 class MockSeat : public Global { 146 class MockSeat : public Global {
131 public: 147 public:
132 MockSeat(); 148 MockSeat();
133 ~MockSeat() override; 149 ~MockSeat() override;
134 150
135 std::unique_ptr<MockPointer> pointer; 151 std::unique_ptr<MockPointer> pointer;
136 152
137 private: 153 private:
138 DISALLOW_COPY_AND_ASSIGN(MockSeat); 154 DISALLOW_COPY_AND_ASSIGN(MockSeat);
139 }; 155 };
(...skipping 25 matching lines...) Expand all
165 // ensuring that this file descriptor gets closed (for example, by calling 181 // ensuring that this file descriptor gets closed (for example, by calling
166 // wl_display_connect). 182 // wl_display_connect).
167 bool Start(); 183 bool Start();
168 184
169 // Pause the server when it becomes idle. 185 // Pause the server when it becomes idle.
170 void Pause(); 186 void Pause();
171 187
172 // Resume the server after flushing client connections. 188 // Resume the server after flushing client connections.
173 void Resume(); 189 void Resume();
174 190
191 void AddDisplay(const display::Display&);
192
175 template <typename T> 193 template <typename T>
176 T* GetObject(uint32_t id) { 194 T* GetObject(uint32_t id) {
177 wl_resource* resource = wl_client_get_object(client_, id); 195 wl_resource* resource = wl_client_get_object(client_, id);
178 return resource ? T::FromResource(resource) : nullptr; 196 return resource ? T::FromResource(resource) : nullptr;
179 } 197 }
180 198
181 MockSeat* seat() { return &seat_; } 199 MockSeat* seat() { return &seat_; }
182 MockXdgShell* xdg_shell() { return &xdg_shell_; } 200 MockXdgShell* xdg_shell() { return &xdg_shell_; }
183 201
184 private: 202 private:
185 void DoPause(); 203 void DoPause();
186 204
187 std::unique_ptr<base::MessagePump> CreateMessagePump(); 205 std::unique_ptr<base::MessagePump> CreateMessagePump();
188 206
189 // base::MessagePumpLibevent::Watcher 207 // base::MessagePumpLibevent::Watcher
190 void OnFileCanReadWithoutBlocking(int fd) override; 208 void OnFileCanReadWithoutBlocking(int fd) override;
191 void OnFileCanWriteWithoutBlocking(int fd) override; 209 void OnFileCanWriteWithoutBlocking(int fd) override;
192 210
193 std::unique_ptr<wl_display, DisplayDeleter> display_; 211 std::unique_ptr<wl_display, DisplayDeleter> display_;
194 wl_client* client_ = nullptr; 212 wl_client* client_ = nullptr;
195 wl_event_loop* event_loop_ = nullptr; 213 wl_event_loop* event_loop_ = nullptr;
196 214
197 base::WaitableEvent pause_event_; 215 base::WaitableEvent pause_event_;
198 base::WaitableEvent resume_event_; 216 base::WaitableEvent resume_event_;
199 bool paused_ = false; 217 bool paused_ = false;
200 218
201 MockCompositor compositor_; 219 MockCompositor compositor_;
220 MockOutput output_;
202 MockSeat seat_; 221 MockSeat seat_;
203 MockXdgShell xdg_shell_; 222 MockXdgShell xdg_shell_;
204 223
205 base::MessagePumpLibevent::FileDescriptorWatcher controller_; 224 base::MessagePumpLibevent::FileDescriptorWatcher controller_;
206 225
207 DISALLOW_COPY_AND_ASSIGN(FakeServer); 226 DISALLOW_COPY_AND_ASSIGN(FakeServer);
208 }; 227 };
209 228
210 } // namespace wl 229 } // namespace wl
211 230
212 #endif // UI_OZONE_PLATFORM_WAYLAND_FAKE_SERVER_H_ 231 #endif // UI_OZONE_PLATFORM_WAYLAND_FAKE_SERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698