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 "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 MOCK_METHOD4(Damage, | 64 MOCK_METHOD4(Damage, |
65 void(int32_t x, int32_t y, int32_t width, int32_t height)); | 65 void(int32_t x, int32_t y, int32_t width, int32_t height)); |
66 MOCK_METHOD0(Commit, void()); | 66 MOCK_METHOD0(Commit, void()); |
67 | 67 |
68 scoped_ptr<MockXdgSurface> xdg_surface; | 68 scoped_ptr<MockXdgSurface> xdg_surface; |
69 | 69 |
70 private: | 70 private: |
71 DISALLOW_COPY_AND_ASSIGN(MockSurface); | 71 DISALLOW_COPY_AND_ASSIGN(MockSurface); |
72 }; | 72 }; |
73 | 73 |
| 74 class MockPointer : public ServerObject { |
| 75 public: |
| 76 MockPointer(wl_resource* resource); |
| 77 ~MockPointer() override; |
| 78 |
| 79 private: |
| 80 DISALLOW_COPY_AND_ASSIGN(MockPointer); |
| 81 }; |
| 82 |
74 struct GlobalDeleter { | 83 struct GlobalDeleter { |
75 void operator()(wl_global* global); | 84 void operator()(wl_global* global); |
76 }; | 85 }; |
77 | 86 |
78 class Global { | 87 class Global { |
79 public: | 88 public: |
80 Global(const wl_interface* interface, | 89 Global(const wl_interface* interface, |
81 const void* implementation, | 90 const void* implementation, |
82 uint32_t version); | 91 uint32_t version); |
83 virtual ~Global(); | 92 virtual ~Global(); |
(...skipping 27 matching lines...) Expand all Loading... |
111 ~MockCompositor() override; | 120 ~MockCompositor() override; |
112 | 121 |
113 void AddSurface(scoped_ptr<MockSurface> surface); | 122 void AddSurface(scoped_ptr<MockSurface> surface); |
114 | 123 |
115 private: | 124 private: |
116 std::vector<scoped_ptr<MockSurface>> surfaces_; | 125 std::vector<scoped_ptr<MockSurface>> surfaces_; |
117 | 126 |
118 DISALLOW_COPY_AND_ASSIGN(MockCompositor); | 127 DISALLOW_COPY_AND_ASSIGN(MockCompositor); |
119 }; | 128 }; |
120 | 129 |
| 130 class MockSeat : public Global { |
| 131 public: |
| 132 MockSeat(); |
| 133 ~MockSeat() override; |
| 134 |
| 135 scoped_ptr<MockPointer> pointer; |
| 136 |
| 137 private: |
| 138 DISALLOW_COPY_AND_ASSIGN(MockSeat); |
| 139 }; |
| 140 |
121 class MockXdgShell : public Global { | 141 class MockXdgShell : public Global { |
122 public: | 142 public: |
123 MockXdgShell(); | 143 MockXdgShell(); |
124 ~MockXdgShell() override; | 144 ~MockXdgShell() override; |
125 | 145 |
126 MOCK_METHOD1(UseUnstableVersion, void(int32_t version)); | 146 MOCK_METHOD1(UseUnstableVersion, void(int32_t version)); |
127 MOCK_METHOD1(Pong, void(uint32_t serial)); | 147 MOCK_METHOD1(Pong, void(uint32_t serial)); |
128 | 148 |
129 private: | 149 private: |
130 DISALLOW_COPY_AND_ASSIGN(MockXdgShell); | 150 DISALLOW_COPY_AND_ASSIGN(MockXdgShell); |
(...skipping 20 matching lines...) Expand all Loading... |
151 void Pause(); | 171 void Pause(); |
152 void Resume(); | 172 void Resume(); |
153 | 173 |
154 template <typename T> | 174 template <typename T> |
155 T* GetObject(uint32_t id) { | 175 T* GetObject(uint32_t id) { |
156 wl_resource* resource = wl_client_get_object(client_, id); | 176 wl_resource* resource = wl_client_get_object(client_, id); |
157 return resource ? T::FromResource(resource) : nullptr; | 177 return resource ? T::FromResource(resource) : nullptr; |
158 } | 178 } |
159 | 179 |
160 MockXdgShell* xdg_shell() { return &xdg_shell_; } | 180 MockXdgShell* xdg_shell() { return &xdg_shell_; } |
| 181 MockSeat* seat() { return &seat_; } |
161 | 182 |
162 private: | 183 private: |
163 void DoPause(); | 184 void DoPause(); |
164 | 185 |
165 scoped_ptr<base::MessagePump> CreateMessagePump(); | 186 scoped_ptr<base::MessagePump> CreateMessagePump(); |
166 | 187 |
167 // base::MessagePumpLibevent::Watcher | 188 // base::MessagePumpLibevent::Watcher |
168 void OnFileCanReadWithoutBlocking(int fd) override; | 189 void OnFileCanReadWithoutBlocking(int fd) override; |
169 void OnFileCanWriteWithoutBlocking(int fd) override; | 190 void OnFileCanWriteWithoutBlocking(int fd) override; |
170 | 191 |
171 scoped_ptr<wl_display, DisplayDeleter> display_; | 192 scoped_ptr<wl_display, DisplayDeleter> display_; |
172 wl_client* client_ = nullptr; | 193 wl_client* client_ = nullptr; |
173 wl_event_loop* event_loop_ = nullptr; | 194 wl_event_loop* event_loop_ = nullptr; |
174 | 195 |
175 base::WaitableEvent pause_event_; | 196 base::WaitableEvent pause_event_; |
176 base::WaitableEvent resume_event_; | 197 base::WaitableEvent resume_event_; |
177 bool paused_ = false; | 198 bool paused_ = false; |
178 | 199 |
179 MockCompositor compositor_; | 200 MockCompositor compositor_; |
| 201 MockSeat seat_; |
180 MockXdgShell xdg_shell_; | 202 MockXdgShell xdg_shell_; |
181 | 203 |
182 base::MessagePumpLibevent::FileDescriptorWatcher controller_; | 204 base::MessagePumpLibevent::FileDescriptorWatcher controller_; |
183 | 205 |
184 DISALLOW_COPY_AND_ASSIGN(FakeServer); | 206 DISALLOW_COPY_AND_ASSIGN(FakeServer); |
185 }; | 207 }; |
186 | 208 |
187 } // namespace wl | 209 } // namespace wl |
188 | 210 |
189 #endif // UI_OZONE_PLATFORM_WAYLAND_FAKE_SERVER_H_ | 211 #endif // UI_OZONE_PLATFORM_WAYLAND_FAKE_SERVER_H_ |
OLD | NEW |