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 "xdgshellclient.h" | 21 | #include "abstract_client.h" | ||
22 | #include "screenlockerwatcher.h" | 22 | #include "screenlockerwatcher.h" | ||
23 | #include "wayland_server.h" | 23 | #include "wayland_server.h" | ||
24 | 24 | | |||
25 | #include <KWayland/Client/compositor.h> | 25 | #include <KWayland/Client/compositor.h> | ||
26 | #include <KWayland/Client/connection_thread.h> | 26 | #include <KWayland/Client/connection_thread.h> | ||
27 | #include <KWayland/Client/event_queue.h> | 27 | #include <KWayland/Client/event_queue.h> | ||
28 | #include <KWayland/Client/idleinhibit.h> | 28 | #include <KWayland/Client/idleinhibit.h> | ||
29 | #include <KWayland/Client/registry.h> | 29 | #include <KWayland/Client/registry.h> | ||
▲ Show 20 Lines • Show All 357 Lines • ▼ Show 20 Line(s) | |||||
387 | 387 | | |||
388 | void render(Surface *surface, const QImage &img) | 388 | void render(Surface *surface, const QImage &img) | ||
389 | { | 389 | { | ||
390 | surface->attachBuffer(s_waylandConnection.shm->createBuffer(img)); | 390 | surface->attachBuffer(s_waylandConnection.shm->createBuffer(img)); | ||
391 | surface->damage(QRect(QPoint(0, 0), img.size())); | 391 | surface->damage(QRect(QPoint(0, 0), img.size())); | ||
392 | surface->commit(Surface::CommitFlag::None); | 392 | surface->commit(Surface::CommitFlag::None); | ||
393 | } | 393 | } | ||
394 | 394 | | |||
395 | XdgShellClient *waitForWaylandWindowShown(int timeout) | 395 | AbstractClient *waitForWaylandWindowShown(int timeout) | ||
396 | { | 396 | { | ||
397 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 397 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
398 | if (!clientAddedSpy.isValid()) { | 398 | if (!clientAddedSpy.isValid()) { | ||
399 | return nullptr; | 399 | return nullptr; | ||
400 | } | 400 | } | ||
401 | if (!clientAddedSpy.wait(timeout)) { | 401 | if (!clientAddedSpy.wait(timeout)) { | ||
402 | return nullptr; | 402 | return nullptr; | ||
403 | } | 403 | } | ||
404 | return clientAddedSpy.first().first().value<XdgShellClient *>(); | 404 | return clientAddedSpy.first().first().value<AbstractClient *>(); | ||
405 | } | 405 | } | ||
406 | 406 | | |||
407 | XdgShellClient *renderAndWaitForShown(Surface *surface, const QSize &size, const QColor &color, const QImage::Format &format, int timeout) | 407 | AbstractClient *renderAndWaitForShown(Surface *surface, const QSize &size, const QColor &color, const QImage::Format &format, int timeout) | ||
408 | { | 408 | { | ||
409 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 409 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
410 | if (!clientAddedSpy.isValid()) { | 410 | if (!clientAddedSpy.isValid()) { | ||
411 | return nullptr; | 411 | return nullptr; | ||
412 | } | 412 | } | ||
413 | render(surface, size, color, format); | 413 | render(surface, size, color, format); | ||
414 | flushWaylandConnection(); | 414 | flushWaylandConnection(); | ||
415 | if (!clientAddedSpy.wait(timeout)) { | 415 | if (!clientAddedSpy.wait(timeout)) { | ||
416 | return nullptr; | 416 | return nullptr; | ||
417 | } | 417 | } | ||
418 | return clientAddedSpy.first().first().value<XdgShellClient *>(); | 418 | return clientAddedSpy.first().first().value<AbstractClient *>(); | ||
419 | } | 419 | } | ||
420 | 420 | | |||
421 | void flushWaylandConnection() | 421 | void flushWaylandConnection() | ||
422 | { | 422 | { | ||
423 | if (s_waylandConnection.connection) { | 423 | if (s_waylandConnection.connection) { | ||
424 | s_waylandConnection.connection->flush(); | 424 | s_waylandConnection.connection->flush(); | ||
425 | } | 425 | } | ||
426 | } | 426 | } | ||
▲ Show 20 Lines • Show All 185 Lines • Show Last 20 Lines |