tests: support ivi-shell again in tst_client

This amends 4767e91f7bd32ee6ffc7701035f430e453b99784.

QT_WAYLAND_SHELL_INTEGRATION=ivi-shell ./tst_client

Task-number: QTBUG-96440
Change-Id: I3c6d06e978c9aab3a2a61797fe359e0b1e90df17
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
Liang Qi 2021-10-07 18:01:59 +02:00
parent 468ac1fefb
commit c98bbc5495
3 changed files with 87 additions and 36 deletions

View File

@ -186,10 +186,10 @@ void tst_WaylandClient::createDestroyWindow()
TestWindow window; TestWindow window;
window.show(); window.show();
QCOMPOSITOR_TRY_VERIFY(wlSurface(0)); QCOMPOSITOR_TRY_VERIFY(surface());
window.destroy(); window.destroy();
QCOMPOSITOR_TRY_VERIFY(!wlSurface(0)); QCOMPOSITOR_TRY_VERIFY(!surface());
} }
void tst_WaylandClient::activeWindowFollowsKeyboardFocus() void tst_WaylandClient::activeWindowFollowsKeyboardFocus()
@ -198,9 +198,10 @@ void tst_WaylandClient::activeWindowFollowsKeyboardFocus()
window.show(); window.show();
Surface *s = nullptr; Surface *s = nullptr;
QCOMPOSITOR_TRY_VERIFY(s = wlSurface(0)); QCOMPOSITOR_TRY_VERIFY(s = surface());
WlShellSurface *ss = s->wlShellSurface(); exec([=] {
ss->sendConfigure(0, 0, 0); sendShellSurfaceConfigure(s);
});
QCOMPOSITOR_TRY_VERIFY(window.isExposed()); QCOMPOSITOR_TRY_VERIFY(window.isExposed());
@ -225,9 +226,10 @@ void tst_WaylandClient::events()
window.show(); window.show();
Surface *s = nullptr; Surface *s = nullptr;
QCOMPOSITOR_TRY_VERIFY(s = wlSurface(0)); QCOMPOSITOR_TRY_VERIFY(s = surface());
WlShellSurface *ss = s->wlShellSurface(); exec([=] {
ss->sendConfigure(0, 0, 0); sendShellSurfaceConfigure(s);
});
QCOMPOSITOR_TRY_VERIFY(window.isExposed()); QCOMPOSITOR_TRY_VERIFY(window.isExposed());
@ -304,9 +306,10 @@ void tst_WaylandClient::backingStore()
window.show(); window.show();
Surface *s = nullptr; Surface *s = nullptr;
QCOMPOSITOR_TRY_VERIFY(s = wlSurface(0)); QCOMPOSITOR_TRY_VERIFY(s = surface());
WlShellSurface *ss = s->wlShellSurface(); exec([=] {
ss->sendConfigure(0, 0, 0); sendShellSurfaceConfigure(s);
});
QRect rect(QPoint(), window.size()); QRect rect(QPoint(), window.size());
@ -333,7 +336,7 @@ void tst_WaylandClient::backingStore()
window.hide(); window.hide();
// hiding the window should destroy the surface // hiding the window should destroy the surface
QCOMPOSITOR_TRY_VERIFY(!wlSurface(0)); QCOMPOSITOR_TRY_VERIFY(!surface());
} }
class DndWindow : public QWindow class DndWindow : public QWindow
@ -414,9 +417,10 @@ void tst_WaylandClient::touchDrag()
window.show(); window.show();
Surface *s = nullptr; Surface *s = nullptr;
QCOMPOSITOR_TRY_VERIFY(s = wlSurface(0)); QCOMPOSITOR_TRY_VERIFY(s = surface());
WlShellSurface *ss = s->wlShellSurface(); exec([=] {
ss->sendConfigure(0, 0, 0); sendShellSurfaceConfigure(s);
});
DNDTest test; DNDTest test;
test.m_surface = s; test.m_surface = s;
@ -450,9 +454,10 @@ void tst_WaylandClient::mouseDrag()
window.show(); window.show();
Surface *s = nullptr; Surface *s = nullptr;
QCOMPOSITOR_TRY_VERIFY(s = wlSurface(0)); QCOMPOSITOR_TRY_VERIFY(s = surface());
WlShellSurface *ss = s->wlShellSurface(); exec([=] {
ss->sendConfigure(0, 0, 0); sendShellSurfaceConfigure(s);
});
DNDTest test; DNDTest test;
test.m_surface = s; test.m_surface = s;
@ -506,11 +511,11 @@ void tst_WaylandClient::dontCrashOnMultipleCommits()
backingStore.flush(rect); backingStore.flush(rect);
backingStore.flush(rect); backingStore.flush(rect);
QCOMPOSITOR_TRY_VERIFY(wlSurface(0)); QCOMPOSITOR_TRY_VERIFY(surface());
} }
delete window; delete window;
QCOMPOSITOR_TRY_VERIFY(!wlSurface(0)); QCOMPOSITOR_TRY_VERIFY(!surface());
} }
void tst_WaylandClient::hiddenTransientParent() void tst_WaylandClient::hiddenTransientParent()
@ -521,13 +526,13 @@ void tst_WaylandClient::hiddenTransientParent()
transient.setTransientParent(&parent); transient.setTransientParent(&parent);
parent.show(); parent.show();
QCOMPOSITOR_TRY_VERIFY(wlSurface(0)); QCOMPOSITOR_TRY_VERIFY(surface());
parent.hide(); parent.hide();
QCOMPOSITOR_TRY_VERIFY(!wlSurface(0)); QCOMPOSITOR_TRY_VERIFY(!surface());
transient.show(); transient.show();
QCOMPOSITOR_TRY_VERIFY(wlSurface(0)); QCOMPOSITOR_TRY_VERIFY(surface());
} }
void tst_WaylandClient::hiddenPopupParent() void tst_WaylandClient::hiddenPopupParent()
{ {
@ -537,9 +542,10 @@ void tst_WaylandClient::hiddenPopupParent()
// wl_shell relies on a mouse event in order to send a serial and seat // wl_shell relies on a mouse event in order to send a serial and seat
// with the set_popup request. // with the set_popup request.
Surface *s = nullptr; Surface *s = nullptr;
QCOMPOSITOR_TRY_VERIFY(s = wlSurface(0)); QCOMPOSITOR_TRY_VERIFY(s = surface());
WlShellSurface *ss = s->wlShellSurface(); exec([=] {
ss->sendConfigure(0, 0, 0); sendShellSurfaceConfigure(s);
});
QCOMPOSITOR_TRY_VERIFY(toplevel.isExposed()); QCOMPOSITOR_TRY_VERIFY(toplevel.isExposed());
QPoint mousePressPos(16, 16); QPoint mousePressPos(16, 16);
@ -559,10 +565,10 @@ void tst_WaylandClient::hiddenPopupParent()
popup.setFlag(Qt::Popup, true); popup.setFlag(Qt::Popup, true);
toplevel.hide(); toplevel.hide();
QCOMPOSITOR_TRY_VERIFY(!wlSurface(0)); QCOMPOSITOR_TRY_VERIFY(!surface());
popup.show(); popup.show();
QCOMPOSITOR_TRY_VERIFY(wlSurface(0)); QCOMPOSITOR_TRY_VERIFY(surface());
} }
#if QT_CONFIG(opengl) #if QT_CONFIG(opengl)
@ -573,9 +579,10 @@ void tst_WaylandClient::glWindow()
QScopedPointer<TestGlWindow> testWindow(new TestGlWindow); QScopedPointer<TestGlWindow> testWindow(new TestGlWindow);
testWindow->show(); testWindow->show();
Surface *s = nullptr; Surface *s = nullptr;
QCOMPOSITOR_TRY_VERIFY(s = wlSurface(0)); QCOMPOSITOR_TRY_VERIFY(s = surface());
WlShellSurface *ss = s->wlShellSurface(); exec([=] {
ss->sendConfigure(0, 0, 0); sendShellSurfaceConfigure(s);
});
QTRY_COMPARE(testWindow->paintGLCalled, 1); QTRY_COMPARE(testWindow->paintGLCalled, 1);
@ -590,7 +597,7 @@ void tst_WaylandClient::glWindow()
//confirm we don't crash when we delete an already hidden GL window //confirm we don't crash when we delete an already hidden GL window
//QTBUG-65553 //QTBUG-65553
testWindow->setVisible(false); testWindow->setVisible(false);
QCOMPOSITOR_TRY_VERIFY(!wlSurface(0)); QCOMPOSITOR_TRY_VERIFY(!surface());
} }
#endif // QT_CONFIG(opengl) #endif // QT_CONFIG(opengl)
@ -601,7 +608,7 @@ void tst_WaylandClient::longWindowTitle()
QString absurdlyLongTitle(10000, QLatin1Char('z')); QString absurdlyLongTitle(10000, QLatin1Char('z'));
window.setTitle(absurdlyLongTitle); window.setTitle(absurdlyLongTitle);
window.show(); window.show();
QCOMPOSITOR_TRY_VERIFY(wlSurface(0)); QCOMPOSITOR_TRY_VERIFY(surface());
} }
void tst_WaylandClient::longWindowTitleWithUtf16Characters() void tst_WaylandClient::longWindowTitleWithUtf16Characters()
@ -611,7 +618,7 @@ void tst_WaylandClient::longWindowTitleWithUtf16Characters()
Q_ASSERT(absurdlyLongTitle.length() == 10000); // just making sure the test isn't broken Q_ASSERT(absurdlyLongTitle.length() == 10000); // just making sure the test isn't broken
window.setTitle(absurdlyLongTitle); window.setTitle(absurdlyLongTitle);
window.show(); window.show();
QCOMPOSITOR_TRY_VERIFY(wlSurface(0)); QCOMPOSITOR_TRY_VERIFY(surface());
} }
int main(int argc, char **argv) int main(int argc, char **argv)
@ -619,7 +626,9 @@ int main(int argc, char **argv)
QTemporaryDir tmpRuntimeDir; QTemporaryDir tmpRuntimeDir;
setenv("XDG_RUNTIME_DIR", tmpRuntimeDir.path().toLocal8Bit(), 1); setenv("XDG_RUNTIME_DIR", tmpRuntimeDir.path().toLocal8Bit(), 1);
setenv("QT_QPA_PLATFORM", "wayland", 1); // force QGuiApplication to use wayland plugin setenv("QT_QPA_PLATFORM", "wayland", 1); // force QGuiApplication to use wayland plugin
setenv("QT_WAYLAND_SHELL_INTEGRATION", "wl-shell", 1); QString shell = QString::fromLocal8Bit(qgetenv("QT_WAYLAND_SHELL_INTEGRATION"));
if (shell.isEmpty())
setenv("QT_WAYLAND_SHELL_INTEGRATION", "wl-shell", 1);
tst_WaylandClient tc; tst_WaylandClient tc;
QGuiApplication app(argc, argv); QGuiApplication app(argc, argv);

View File

@ -79,6 +79,27 @@ DefaultCompositor::DefaultCompositor(CompositorType t)
Q_ASSERT(isClean()); Q_ASSERT(isClean());
} }
Surface *DefaultCompositor::surface(int i)
{
Surface *result = nullptr;
switch (m_type) {
case CompositorType::Default:
result = get<WlCompositor>()->m_surfaces.value(i, nullptr);
break;
case CompositorType::Legacy: {
QList<Surface *> surfaces = get<WlCompositor>()->m_surfaces;
for (Surface *surface : surfaces) {
if (surface->isMapped()) {
result = surface;
break;
}
}
}
break;
}
return result;
}
uint DefaultCompositor::sendXdgShellPing() uint DefaultCompositor::sendXdgShellPing()
{ {
warnIfNotLockedByThread(Q_FUNC_INFO); warnIfNotLockedByThread(Q_FUNC_INFO);
@ -98,6 +119,23 @@ void DefaultCompositor::xdgPingAndWaitForPong()
QTRY_COMPARE(pongSpy.first().at(0).toUInt(), serial); QTRY_COMPARE(pongSpy.first().at(0).toUInt(), serial);
} }
void DefaultCompositor::sendShellSurfaceConfigure(Surface *surface)
{
switch (m_type) {
case CompositorType::Default:
break;
case CompositorType::Legacy: {
if (auto wlShellSurface = surface->wlShellSurface()) {
wlShellSurface->sendConfigure(0, 0, 0);
return;
}
break;
}
}
qWarning() << "The mocking framework doesn't know how to send a configure event for this surface";
}
WlShellCompositor::WlShellCompositor(CompositorType t) WlShellCompositor::WlShellCompositor(CompositorType t)
: DefaultCompositor(t) : DefaultCompositor(t)
{ {

View File

@ -58,7 +58,7 @@ public:
explicit DefaultCompositor(CompositorType t = CompositorType::Default); explicit DefaultCompositor(CompositorType t = CompositorType::Default);
// Convenience functions // Convenience functions
Output *output(int i = 0) { return getAll<Output>().value(i, nullptr); } Output *output(int i = 0) { return getAll<Output>().value(i, nullptr); }
Surface *surface(int i = 0) { return get<WlCompositor>()->m_surfaces.value(i, nullptr); } Surface *surface(int i = 0);
Subsurface *subSurface(int i = 0) { return get<SubCompositor>()->m_subsurfaces.value(i, nullptr); } Subsurface *subSurface(int i = 0) { return get<SubCompositor>()->m_subsurfaces.value(i, nullptr); }
WlShellSurface *wlShellSurface(int i = 0) { return get<WlShell>()->m_wlShellSurfaces.value(i, nullptr); } WlShellSurface *wlShellSurface(int i = 0) { return get<WlShell>()->m_wlShellSurfaces.value(i, nullptr); }
Surface *wlSurface(int i = 0); Surface *wlSurface(int i = 0);
@ -71,8 +71,12 @@ public:
Keyboard *keyboard() { auto *seat = get<Seat>(); Q_ASSERT(seat); return seat->m_keyboard; } Keyboard *keyboard() { auto *seat = get<Seat>(); Q_ASSERT(seat); return seat->m_keyboard; }
FullScreenShellV1 *fullScreenShellV1() {return get<FullScreenShellV1>();}; FullScreenShellV1 *fullScreenShellV1() {return get<FullScreenShellV1>();};
IviSurface *iviSurface(int i = 0) { return get<IviApplication>()->m_iviSurfaces.value(i, nullptr); } IviSurface *iviSurface(int i = 0) { return get<IviApplication>()->m_iviSurfaces.value(i, nullptr); }
uint sendXdgShellPing(); uint sendXdgShellPing();
void xdgPingAndWaitForPong(); void xdgPingAndWaitForPong();
void sendShellSurfaceConfigure(Surface *surface);
// Things that can be changed run-time without confusing the client (i.e. don't require separate tests) // Things that can be changed run-time without confusing the client (i.e. don't require separate tests)
struct Config { struct Config {
bool autoEnter = true; bool autoEnter = true;