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

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: rebase on master Created 4 years, 5 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/gfx/geometry/rect.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 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() {}
rjkroege 2016/07/25 23:45:46 Method docs? My dream is to have docs approaching
joone 2016/09/21 21:21:22 Done.
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 {
rjkroege 2016/07/25 23:45:46 Say what Global is please.
joone 2016/09/21 21:21:22 Done.
133 public:
134 MockOutput();
135 ~MockOutput() override;
136 void SetRect(const gfx::Rect rect) { rect_ = rect; }
137 const gfx::Rect GetRect() { return rect_; }
138 void OnBind() override;
139
140 private:
141 gfx::Rect rect_;
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 void Resume(); 189 void Resume();
174 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_; }
199 MockOutput* output() { return &output_; }
183 200
184 private: 201 private:
185 void DoPause(); 202 void DoPause();
186 203
187 std::unique_ptr<base::MessagePump> CreateMessagePump(); 204 std::unique_ptr<base::MessagePump> CreateMessagePump();
188 205
189 // base::MessagePumpLibevent::Watcher 206 // base::MessagePumpLibevent::Watcher
190 void OnFileCanReadWithoutBlocking(int fd) override; 207 void OnFileCanReadWithoutBlocking(int fd) override;
191 void OnFileCanWriteWithoutBlocking(int fd) override; 208 void OnFileCanWriteWithoutBlocking(int fd) override;
192 209
193 std::unique_ptr<wl_display, DisplayDeleter> display_; 210 std::unique_ptr<wl_display, DisplayDeleter> display_;
194 wl_client* client_ = nullptr; 211 wl_client* client_ = nullptr;
195 wl_event_loop* event_loop_ = nullptr; 212 wl_event_loop* event_loop_ = nullptr;
196 213
197 base::WaitableEvent pause_event_; 214 base::WaitableEvent pause_event_;
198 base::WaitableEvent resume_event_; 215 base::WaitableEvent resume_event_;
199 216
200 MockCompositor compositor_; 217 MockCompositor compositor_;
218 MockOutput output_;
201 MockSeat seat_; 219 MockSeat seat_;
202 MockXdgShell xdg_shell_; 220 MockXdgShell xdg_shell_;
203 221
204 base::MessagePumpLibevent::FileDescriptorWatcher controller_; 222 base::MessagePumpLibevent::FileDescriptorWatcher controller_;
205 223
206 DISALLOW_COPY_AND_ASSIGN(FakeServer); 224 DISALLOW_COPY_AND_ASSIGN(FakeServer);
207 }; 225 };
208 226
209 } // namespace wl 227 } // namespace wl
210 228
211 #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