Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/test_helpers.cpp
Show All 12 Lines | |||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "kwin_wayland_test.h" | 20 | #include "kwin_wayland_test.h" | ||
21 | #include "shell_client.h" | ||||
22 | #include "wayland_server.h" | ||||
21 | 23 | | |||
22 | #include <KWayland/Client/compositor.h> | 24 | #include <KWayland/Client/compositor.h> | ||
23 | #include <KWayland/Client/connection_thread.h> | 25 | #include <KWayland/Client/connection_thread.h> | ||
24 | #include <KWayland/Client/event_queue.h> | 26 | #include <KWayland/Client/event_queue.h> | ||
25 | #include <KWayland/Client/registry.h> | 27 | #include <KWayland/Client/registry.h> | ||
26 | #include <KWayland/Client/plasmashell.h> | 28 | #include <KWayland/Client/plasmashell.h> | ||
27 | #include <KWayland/Client/plasmawindowmanagement.h> | 29 | #include <KWayland/Client/plasmawindowmanagement.h> | ||
28 | #include <KWayland/Client/seat.h> | 30 | #include <KWayland/Client/seat.h> | ||
▲ Show 20 Lines • Show All 210 Lines • ▼ Show 20 Line(s) | |||||
239 | { | 241 | { | ||
240 | QImage img(size, format); | 242 | QImage img(size, format); | ||
241 | img.fill(color); | 243 | img.fill(color); | ||
242 | surface->attachBuffer(s_waylandConnection.shm->createBuffer(img)); | 244 | surface->attachBuffer(s_waylandConnection.shm->createBuffer(img)); | ||
243 | surface->damage(QRect(QPoint(0, 0), size)); | 245 | surface->damage(QRect(QPoint(0, 0), size)); | ||
244 | surface->commit(Surface::CommitFlag::None); | 246 | surface->commit(Surface::CommitFlag::None); | ||
245 | } | 247 | } | ||
246 | 248 | | |||
249 | ShellClient *waitForWaylandWindowShown(int timeout) | ||||
250 | { | ||||
251 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||||
252 | if (!clientAddedSpy.isValid()) { | ||||
253 | return nullptr; | ||||
254 | } | ||||
255 | if (!clientAddedSpy.wait(timeout)) { | ||||
256 | return nullptr; | ||||
257 | } | ||||
258 | return clientAddedSpy.first().first().value<ShellClient*>(); | ||||
259 | } | ||||
260 | | ||||
261 | ShellClient *renderAndWaitForShown(Surface *surface, const QSize &size, const QColor &color, const QImage::Format &format, int timeout) | ||||
262 | { | ||||
263 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||||
264 | if (!clientAddedSpy.isValid()) { | ||||
265 | return nullptr; | ||||
266 | } | ||||
267 | render(surface, size, color, format); | ||||
268 | flushWaylandConnection(); | ||||
269 | if (!clientAddedSpy.wait(timeout)) { | ||||
270 | return nullptr; | ||||
271 | } | ||||
272 | return clientAddedSpy.first().first().value<ShellClient*>(); | ||||
273 | } | ||||
274 | | ||||
247 | void flushWaylandConnection() | 275 | void flushWaylandConnection() | ||
248 | { | 276 | { | ||
249 | if (s_waylandConnection.connection) { | 277 | if (s_waylandConnection.connection) { | ||
250 | s_waylandConnection.connection->flush(); | 278 | s_waylandConnection.connection->flush(); | ||
251 | } | 279 | } | ||
252 | } | 280 | } | ||
253 | 281 | | |||
254 | Surface *createSurface(QObject *parent) | 282 | Surface *createSurface(QObject *parent) | ||
Show All 27 Lines |