| 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 #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 <memory> |
| 11 |
| 10 #include "base/bind.h" | 12 #include "base/bind.h" |
| 11 #include "base/message_loop/message_pump_libevent.h" | 13 #include "base/files/file_descriptor_watcher_posix.h" |
| 12 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
| 13 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "ui/gfx/geometry/rect.h" | 17 #include "ui/gfx/geometry/rect.h" |
| 16 | 18 |
| 17 struct wl_client; | 19 struct wl_client; |
| 18 struct wl_display; | 20 struct wl_display; |
| 19 struct wl_event_loop; | 21 struct wl_event_loop; |
| 20 struct wl_global; | 22 struct wl_global; |
| 21 struct wl_resource; | 23 struct wl_resource; |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 MOCK_METHOD1(Pong, void(uint32_t serial)); | 177 MOCK_METHOD1(Pong, void(uint32_t serial)); |
| 176 | 178 |
| 177 private: | 179 private: |
| 178 DISALLOW_COPY_AND_ASSIGN(MockXdgShell); | 180 DISALLOW_COPY_AND_ASSIGN(MockXdgShell); |
| 179 }; | 181 }; |
| 180 | 182 |
| 181 struct DisplayDeleter { | 183 struct DisplayDeleter { |
| 182 void operator()(wl_display* display); | 184 void operator()(wl_display* display); |
| 183 }; | 185 }; |
| 184 | 186 |
| 185 class FakeServer : public base::Thread, base::MessagePumpLibevent::Watcher { | 187 class FakeServer : public base::Thread { |
| 186 public: | 188 public: |
| 187 FakeServer(); | 189 FakeServer(); |
| 188 ~FakeServer() override; | 190 ~FakeServer() override; |
| 189 | 191 |
| 190 // Start the fake Wayland server. If this succeeds, the WAYLAND_SOCKET | 192 // Start the fake Wayland server. If this succeeds, the WAYLAND_SOCKET |
| 191 // environment variable will be set to the string representation of a file | 193 // environment variable will be set to the string representation of a file |
| 192 // descriptor that a client can connect to. The caller is responsible for | 194 // descriptor that a client can connect to. The caller is responsible for |
| 193 // ensuring that this file descriptor gets closed (for example, by calling | 195 // ensuring that this file descriptor gets closed (for example, by calling |
| 194 // wl_display_connect). | 196 // wl_display_connect). |
| 195 bool Start(); | 197 bool Start(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 206 return resource ? T::FromResource(resource) : nullptr; | 208 return resource ? T::FromResource(resource) : nullptr; |
| 207 } | 209 } |
| 208 | 210 |
| 209 MockSeat* seat() { return &seat_; } | 211 MockSeat* seat() { return &seat_; } |
| 210 MockXdgShell* xdg_shell() { return &xdg_shell_; } | 212 MockXdgShell* xdg_shell() { return &xdg_shell_; } |
| 211 MockOutput* output() { return &output_; } | 213 MockOutput* output() { return &output_; } |
| 212 | 214 |
| 213 private: | 215 private: |
| 214 void DoPause(); | 216 void DoPause(); |
| 215 | 217 |
| 216 std::unique_ptr<base::MessagePump> CreateMessagePump(); | 218 void StartWatchingFileDescriptor(); |
| 217 | 219 |
| 218 // base::MessagePumpLibevent::Watcher | 220 void OnFileCanReadWithoutBlocking(); |
| 219 void OnFileCanReadWithoutBlocking(int fd) override; | |
| 220 void OnFileCanWriteWithoutBlocking(int fd) override; | |
| 221 | 221 |
| 222 std::unique_ptr<wl_display, DisplayDeleter> display_; | 222 std::unique_ptr<wl_display, DisplayDeleter> display_; |
| 223 wl_client* client_ = nullptr; | 223 wl_client* client_ = nullptr; |
| 224 wl_event_loop* event_loop_ = nullptr; | 224 wl_event_loop* event_loop_ = nullptr; |
| 225 | 225 |
| 226 base::WaitableEvent pause_event_; | 226 base::WaitableEvent pause_event_; |
| 227 base::WaitableEvent resume_event_; | 227 base::WaitableEvent resume_event_; |
| 228 | 228 |
| 229 // Represent Wayland global objects | 229 // Represent Wayland global objects |
| 230 MockCompositor compositor_; | 230 MockCompositor compositor_; |
| 231 MockOutput output_; | 231 MockOutput output_; |
| 232 MockSeat seat_; | 232 MockSeat seat_; |
| 233 MockXdgShell xdg_shell_; | 233 MockXdgShell xdg_shell_; |
| 234 | 234 |
| 235 base::MessagePumpLibevent::FileDescriptorWatcher controller_; | 235 std::unique_ptr<base::FileDescriptorWatcher::Controller> controller_; |
| 236 | 236 |
| 237 DISALLOW_COPY_AND_ASSIGN(FakeServer); | 237 DISALLOW_COPY_AND_ASSIGN(FakeServer); |
| 238 }; | 238 }; |
| 239 | 239 |
| 240 } // namespace wl | 240 } // namespace wl |
| 241 | 241 |
| 242 #endif // UI_OZONE_PLATFORM_WAYLAND_FAKE_SERVER_H_ | 242 #endif // UI_OZONE_PLATFORM_WAYLAND_FAKE_SERVER_H_ |
| OLD | NEW |