summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2019-02-06 09:31:41 +0100
committerJohan Helsing <johan.helsing@qt.io>2019-02-27 11:48:56 +0000
commit19e4f721c596a1a2f6446e24e7993b0e6d8a91a7 (patch)
tree37970e48a5f88f4a06789ecb94119c7f68c8c3e6 /tests
parent021bd4d7ed1f4221a0132e21ef0ee5b07f74be3e (diff)
Client tests: Add convenience for getting cursor surface
Let's simplify all those pointer()->surfaceCursor() calls. Change-Id: I83c51f460fa2313a0b84c8c64509d48027156443 Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/client/seatv4/tst_seatv4.cpp62
-rw-r--r--tests/auto/client/shared/mockcompositor.h1
2 files changed, 32 insertions, 31 deletions
diff --git a/tests/auto/client/seatv4/tst_seatv4.cpp b/tests/auto/client/seatv4/tst_seatv4.cpp
index 8fa81b608..771307d7e 100644
--- a/tests/auto/client/seatv4/tst_seatv4.cpp
+++ b/tests/auto/client/seatv4/tst_seatv4.cpp
@@ -133,7 +133,7 @@ void tst_seatv4::setsCursorOnEnter()
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
exec([=] { pointer()->sendEnter(xdgSurface()->m_surface, {32, 32}); });
- QCOMPOSITOR_TRY_VERIFY(pointer()->cursorSurface());
+ QCOMPOSITOR_TRY_VERIFY(cursorSurface());
}
void tst_seatv4::usesEnterSerial()
@@ -339,20 +339,20 @@ void tst_seatv4::scaledCursor()
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
exec([=] { pointer()->sendEnter(xdgSurface()->m_surface, {32, 32}); });
- QCOMPOSITOR_TRY_VERIFY(pointer()->cursorSurface());
- QCOMPOSITOR_TRY_VERIFY(pointer()->cursorSurface()->m_committed.buffer);
- QCOMPOSITOR_TRY_COMPARE(pointer()->cursorSurface()->m_committed.bufferScale, 1);
+ QCOMPOSITOR_TRY_VERIFY(cursorSurface());
+ QCOMPOSITOR_TRY_VERIFY(cursorSurface()->m_committed.buffer);
+ QCOMPOSITOR_TRY_COMPARE(cursorSurface()->m_committed.bufferScale, 1);
QSize unscaledPixelSize = exec([=] {
- return pointer()->cursorSurface()->m_committed.buffer->size();
+ return cursorSurface()->m_committed.buffer->size();
});
exec([=] {
- auto *surface = pointer()->cursorSurface();
+ auto *surface = cursorSurface();
surface->sendEnter(getAll<Output>()[1]);
surface->sendLeave(getAll<Output>()[0]);
});
- QCOMPOSITOR_TRY_COMPARE(pointer()->cursorSurface()->m_committed.buffer->size(), unscaledPixelSize * 2);
+ QCOMPOSITOR_TRY_COMPARE(cursorSurface()->m_committed.buffer->size(), unscaledPixelSize * 2);
// Remove the extra output to clean up for the next test
exec([&] { remove(output(1)); });
@@ -380,11 +380,11 @@ void tst_seatv4::unscaledFallbackCursor()
window.show();
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
exec([=] { pointer()->sendEnter(xdgSurface()->m_surface, {32, 32}); });
- QCOMPOSITOR_TRY_VERIFY(pointer()->cursorSurface());
- QCOMPOSITOR_TRY_VERIFY(pointer()->cursorSurface()->m_committed.buffer);
- QCOMPOSITOR_TRY_COMPARE(pointer()->cursorSurface()->m_committed.bufferScale, 1);
+ QCOMPOSITOR_TRY_VERIFY(cursorSurface());
+ QCOMPOSITOR_TRY_VERIFY(cursorSurface()->m_committed.buffer);
+ QCOMPOSITOR_TRY_COMPARE(cursorSurface()->m_committed.bufferScale, 1);
QSize unscaledPixelSize = exec([=] {
- return pointer()->cursorSurface()->m_committed.buffer->size();
+ return cursorSurface()->m_committed.buffer->size();
});
QCOMPARE(unscaledPixelSize.width(), int(defaultSize));
@@ -392,7 +392,7 @@ void tst_seatv4::unscaledFallbackCursor()
for (int i = 1; i < screens; ++i) {
exec([=] {
- auto *surface = pointer()->cursorSurface();
+ auto *surface = cursorSurface();
surface->sendEnter(getAll<Output>()[i]);
surface->sendLeave(getAll<Output>()[i-1]);
});
@@ -400,7 +400,7 @@ void tst_seatv4::unscaledFallbackCursor()
xdgPingAndWaitForPong(); // Give the client a chance to mess up
// Surface size (buffer size / scale) should stay constant
- QCOMPOSITOR_TRY_COMPARE(pointer()->cursorSurface()->m_committed.buffer->size() / pointer()->cursorSurface()->m_committed.bufferScale, unscaledPixelSize);
+ QCOMPOSITOR_TRY_COMPARE(cursorSurface()->m_committed.buffer->size() / cursorSurface()->m_committed.bufferScale, unscaledPixelSize);
}
// Remove the extra outputs to clean up for the next test
@@ -430,14 +430,14 @@ void tst_seatv4::bitmapCursor()
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
exec([=] { pointer()->sendEnter(xdgSurface()->m_surface, {32, 32}); });
- QCOMPOSITOR_TRY_VERIFY(pointer()->cursorSurface());
- QCOMPOSITOR_TRY_VERIFY(pointer()->cursorSurface()->m_committed.buffer);
- QCOMPOSITOR_COMPARE(pointer()->cursorSurface()->m_committed.buffer->size(), QSize(24, 24));
- QCOMPOSITOR_COMPARE(pointer()->cursorSurface()->m_committed.bufferScale, 1);
+ QCOMPOSITOR_TRY_VERIFY(cursorSurface());
+ QCOMPOSITOR_TRY_VERIFY(cursorSurface()->m_committed.buffer);
+ QCOMPOSITOR_COMPARE(cursorSurface()->m_committed.buffer->size(), QSize(24, 24));
+ QCOMPOSITOR_COMPARE(cursorSurface()->m_committed.bufferScale, 1);
QCOMPOSITOR_COMPARE(pointer()->m_hotspot, QPoint(12, 12));
exec([=] {
- auto *surface = pointer()->cursorSurface();
+ auto *surface = cursorSurface();
surface->sendEnter(getAll<Output>()[1]);
surface->sendLeave(getAll<Output>()[0]);
});
@@ -445,8 +445,8 @@ void tst_seatv4::bitmapCursor()
xdgPingAndWaitForPong();
// Everything should remain the same, the cursor still has dpr 1
- QCOMPOSITOR_COMPARE(pointer()->cursorSurface()->m_committed.bufferScale, 1);
- QCOMPOSITOR_COMPARE(pointer()->cursorSurface()->m_committed.buffer->size(), QSize(24, 24));
+ QCOMPOSITOR_COMPARE(cursorSurface()->m_committed.bufferScale, 1);
+ QCOMPOSITOR_COMPARE(cursorSurface()->m_committed.buffer->size(), QSize(24, 24));
QCOMPOSITOR_COMPARE(pointer()->m_hotspot, QPoint(12, 12));
// Remove the extra output to clean up for the next test
@@ -476,22 +476,22 @@ void tst_seatv4::hidpiBitmapCursor()
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
exec([=] { pointer()->sendEnter(xdgSurface()->m_surface, {32, 32}); });
- QCOMPOSITOR_TRY_VERIFY(pointer()->cursorSurface());
- QCOMPOSITOR_TRY_VERIFY(pointer()->cursorSurface()->m_committed.buffer);
- QCOMPOSITOR_COMPARE(pointer()->cursorSurface()->m_committed.buffer->size(), QSize(48, 48));
- QCOMPOSITOR_COMPARE(pointer()->cursorSurface()->m_committed.bufferScale, 2);
+ QCOMPOSITOR_TRY_VERIFY(cursorSurface());
+ QCOMPOSITOR_TRY_VERIFY(cursorSurface()->m_committed.buffer);
+ QCOMPOSITOR_COMPARE(cursorSurface()->m_committed.buffer->size(), QSize(48, 48));
+ QCOMPOSITOR_COMPARE(cursorSurface()->m_committed.bufferScale, 2);
QCOMPOSITOR_COMPARE(pointer()->m_hotspot, QPoint(12, 12));
exec([=] {
- auto *surface = pointer()->cursorSurface();
+ auto *surface = cursorSurface();
surface->sendEnter(getAll<Output>()[1]);
surface->sendLeave(getAll<Output>()[0]);
});
xdgPingAndWaitForPong();
- QCOMPOSITOR_COMPARE(pointer()->cursorSurface()->m_committed.bufferScale, 2);
- QCOMPOSITOR_COMPARE(pointer()->cursorSurface()->m_committed.buffer->size(), QSize(48, 48));
+ QCOMPOSITOR_COMPARE(cursorSurface()->m_committed.bufferScale, 2);
+ QCOMPOSITOR_COMPARE(cursorSurface()->m_committed.buffer->size(), QSize(48, 48));
QCOMPOSITOR_COMPARE(pointer()->m_hotspot, QPoint(12, 12));
// Remove the extra output to clean up for the next test
@@ -513,10 +513,10 @@ void tst_seatv4::hidpiBitmapCursorNonInt()
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
exec([=] { pointer()->sendEnter(xdgSurface()->m_surface, {32, 32}); });
- QCOMPOSITOR_TRY_VERIFY(pointer()->cursorSurface());
- QCOMPOSITOR_TRY_VERIFY(pointer()->cursorSurface()->m_committed.buffer);
- QCOMPOSITOR_COMPARE(pointer()->cursorSurface()->m_committed.buffer->size(), QSize(100, 100));
- QCOMPOSITOR_COMPARE(pointer()->cursorSurface()->m_committed.bufferScale, 2);
+ QCOMPOSITOR_TRY_VERIFY(cursorSurface());
+ QCOMPOSITOR_TRY_VERIFY(cursorSurface()->m_committed.buffer);
+ QCOMPOSITOR_COMPARE(cursorSurface()->m_committed.buffer->size(), QSize(100, 100));
+ QCOMPOSITOR_COMPARE(cursorSurface()->m_committed.bufferScale, 2);
// Verify that the hotspot was scaled correctly
// Surface size is now 100 / 2 = 50, so the middle should be at 25 in surface coordinates
QCOMPOSITOR_COMPARE(pointer()->m_hotspot, QPoint(25, 25));
diff --git a/tests/auto/client/shared/mockcompositor.h b/tests/auto/client/shared/mockcompositor.h
index ddbd7f342..75ef1eaea 100644
--- a/tests/auto/client/shared/mockcompositor.h
+++ b/tests/auto/client/shared/mockcompositor.h
@@ -54,6 +54,7 @@ public:
XdgToplevel *xdgToplevel(int i = 0) { return get<XdgWmBase>()->toplevel(i); }
XdgPopup *xdgPopup(int i = 0) { return get<XdgWmBase>()->popup(i); }
Pointer *pointer() { auto *seat = get<Seat>(); Q_ASSERT(seat); return seat->m_pointer; }
+ Surface *cursorSurface() { auto *p = pointer(); return p ? p->cursorSurface() : nullptr; }
Keyboard *keyboard() { auto *seat = get<Seat>(); Q_ASSERT(seat); return seat->m_keyboard; }
uint sendXdgShellPing();
void xdgPingAndWaitForPong();