diff options
author | Liang Qi <liang.qi@qt.io> | 2021-10-07 18:01:59 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2021-10-19 10:22:59 +0200 |
commit | 0154d0b65b139c4919a020c29846f56697b5b42c (patch) | |
tree | c662f19868e63992bfa44903217bf2e5a9997e70 /tests | |
parent | 92a7904d9651348b0c307e84251c8440c6f75b22 (diff) | |
download | qtwayland-0154d0b65b139c4919a020c29846f56697b5b42c.tar.gz |
tests: support ivi-shell again in tst_client
This amends 4825cf5b476b69cc4c5371535a5d10564d33aed1.
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>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/client/client/tst_client.cpp | 79 | ||||
-rw-r--r-- | tests/auto/client/shared/iviapplication.cpp | 5 | ||||
-rw-r--r-- | tests/auto/client/shared/iviapplication.h | 4 | ||||
-rw-r--r-- | tests/auto/client/shared/mockcompositor.cpp | 38 | ||||
-rw-r--r-- | tests/auto/client/shared/mockcompositor.h | 6 |
5 files changed, 93 insertions, 39 deletions
diff --git a/tests/auto/client/client/tst_client.cpp b/tests/auto/client/client/tst_client.cpp index b16dffbe..8ae79f34 100644 --- a/tests/auto/client/client/tst_client.cpp +++ b/tests/auto/client/client/tst_client.cpp @@ -186,10 +186,10 @@ void tst_WaylandClient::createDestroyWindow() TestWindow window; window.show(); - QCOMPOSITOR_TRY_VERIFY(wlSurface(0)); + QCOMPOSITOR_TRY_VERIFY(surface()); window.destroy(); - QCOMPOSITOR_TRY_VERIFY(!wlSurface(0)); + QCOMPOSITOR_TRY_VERIFY(!surface()); } void tst_WaylandClient::activeWindowFollowsKeyboardFocus() @@ -198,9 +198,10 @@ void tst_WaylandClient::activeWindowFollowsKeyboardFocus() window.show(); Surface *s = nullptr; - QCOMPOSITOR_TRY_VERIFY(s = wlSurface(0)); - WlShellSurface *ss = s->wlShellSurface(); - ss->sendConfigure(0, 0, 0); + QCOMPOSITOR_TRY_VERIFY(s = surface()); + exec([=] { + sendShellSurfaceConfigure(s); + }); QCOMPOSITOR_TRY_VERIFY(window.isExposed()); @@ -225,9 +226,10 @@ void tst_WaylandClient::events() window.show(); Surface *s = nullptr; - QCOMPOSITOR_TRY_VERIFY(s = wlSurface(0)); - WlShellSurface *ss = s->wlShellSurface(); - ss->sendConfigure(0, 0, 0); + QCOMPOSITOR_TRY_VERIFY(s = surface()); + exec([=] { + sendShellSurfaceConfigure(s); + }); QCOMPOSITOR_TRY_VERIFY(window.isExposed()); @@ -304,9 +306,10 @@ void tst_WaylandClient::backingStore() window.show(); Surface *s = nullptr; - QCOMPOSITOR_TRY_VERIFY(s = wlSurface(0)); - WlShellSurface *ss = s->wlShellSurface(); - ss->sendConfigure(0, 0, 0); + QCOMPOSITOR_TRY_VERIFY(s = surface()); + exec([=] { + sendShellSurfaceConfigure(s); + }); QRect rect(QPoint(), window.size()); @@ -333,7 +336,7 @@ void tst_WaylandClient::backingStore() window.hide(); // hiding the window should destroy the surface - QCOMPOSITOR_TRY_VERIFY(!wlSurface(0)); + QCOMPOSITOR_TRY_VERIFY(!surface()); } class DndWindow : public QWindow @@ -414,9 +417,10 @@ void tst_WaylandClient::touchDrag() window.show(); Surface *s = nullptr; - QCOMPOSITOR_TRY_VERIFY(s = wlSurface(0)); - WlShellSurface *ss = s->wlShellSurface(); - ss->sendConfigure(0, 0, 0); + QCOMPOSITOR_TRY_VERIFY(s = surface()); + exec([=] { + sendShellSurfaceConfigure(s); + }); DNDTest test; test.m_surface = s; @@ -450,9 +454,10 @@ void tst_WaylandClient::mouseDrag() window.show(); Surface *s = nullptr; - QCOMPOSITOR_TRY_VERIFY(s = wlSurface(0)); - WlShellSurface *ss = s->wlShellSurface(); - ss->sendConfigure(0, 0, 0); + QCOMPOSITOR_TRY_VERIFY(s = surface()); + exec([=] { + sendShellSurfaceConfigure(s); + }); DNDTest test; test.m_surface = s; @@ -506,11 +511,11 @@ void tst_WaylandClient::dontCrashOnMultipleCommits() backingStore.flush(rect); backingStore.flush(rect); - QCOMPOSITOR_TRY_VERIFY(wlSurface(0)); + QCOMPOSITOR_TRY_VERIFY(surface()); } delete window; - QCOMPOSITOR_TRY_VERIFY(!wlSurface(0)); + QCOMPOSITOR_TRY_VERIFY(!surface()); } void tst_WaylandClient::hiddenTransientParent() @@ -521,13 +526,13 @@ void tst_WaylandClient::hiddenTransientParent() transient.setTransientParent(&parent); parent.show(); - QCOMPOSITOR_TRY_VERIFY(wlSurface(0)); + QCOMPOSITOR_TRY_VERIFY(surface()); parent.hide(); - QCOMPOSITOR_TRY_VERIFY(!wlSurface(0)); + QCOMPOSITOR_TRY_VERIFY(!surface()); transient.show(); - QCOMPOSITOR_TRY_VERIFY(wlSurface(0)); + QCOMPOSITOR_TRY_VERIFY(surface()); } 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 // with the set_popup request. Surface *s = nullptr; - QCOMPOSITOR_TRY_VERIFY(s = wlSurface(0)); - WlShellSurface *ss = s->wlShellSurface(); - ss->sendConfigure(0, 0, 0); + QCOMPOSITOR_TRY_VERIFY(s = surface()); + exec([=] { + sendShellSurfaceConfigure(s); + }); QCOMPOSITOR_TRY_VERIFY(toplevel.isExposed()); QPoint mousePressPos(16, 16); @@ -559,10 +565,10 @@ void tst_WaylandClient::hiddenPopupParent() popup.setFlag(Qt::Popup, true); toplevel.hide(); - QCOMPOSITOR_TRY_VERIFY(!wlSurface(0)); + QCOMPOSITOR_TRY_VERIFY(!surface()); popup.show(); - QCOMPOSITOR_TRY_VERIFY(wlSurface(0)); + QCOMPOSITOR_TRY_VERIFY(surface()); } #if QT_CONFIG(opengl) @@ -573,9 +579,10 @@ void tst_WaylandClient::glWindow() QScopedPointer<TestGlWindow> testWindow(new TestGlWindow); testWindow->show(); Surface *s = nullptr; - QCOMPOSITOR_TRY_VERIFY(s = wlSurface(0)); - WlShellSurface *ss = s->wlShellSurface(); - ss->sendConfigure(0, 0, 0); + QCOMPOSITOR_TRY_VERIFY(s = surface()); + exec([=] { + sendShellSurfaceConfigure(s); + }); 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 //QTBUG-65553 testWindow->setVisible(false); - QCOMPOSITOR_TRY_VERIFY(!wlSurface(0)); + QCOMPOSITOR_TRY_VERIFY(!surface()); } #endif // QT_CONFIG(opengl) @@ -601,7 +608,7 @@ void tst_WaylandClient::longWindowTitle() QString absurdlyLongTitle(10000, QLatin1Char('z')); window.setTitle(absurdlyLongTitle); window.show(); - QCOMPOSITOR_TRY_VERIFY(wlSurface(0)); + QCOMPOSITOR_TRY_VERIFY(surface()); } 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 window.setTitle(absurdlyLongTitle); window.show(); - QCOMPOSITOR_TRY_VERIFY(wlSurface(0)); + QCOMPOSITOR_TRY_VERIFY(surface()); } int main(int argc, char **argv) @@ -619,7 +626,9 @@ int main(int argc, char **argv) QTemporaryDir tmpRuntimeDir; setenv("XDG_RUNTIME_DIR", tmpRuntimeDir.path().toLocal8Bit(), 1); 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; QGuiApplication app(argc, argv); diff --git a/tests/auto/client/shared/iviapplication.cpp b/tests/auto/client/shared/iviapplication.cpp index 98a0b820..161e0181 100644 --- a/tests/auto/client/shared/iviapplication.cpp +++ b/tests/auto/client/shared/iviapplication.cpp @@ -47,8 +47,9 @@ IviSurface::IviSurface(IviApplication *iviApplication, Surface *surface, uint32_ : QtWaylandServer::ivi_surface(client, id, version) , m_iviId(ivi_id) , m_iviApplication(iviApplication) + , m_surface(surface) { - Q_UNUSED(surface); + surface->map(); } void IviSurface::ivi_surface_destroy_resource(Resource *resource) @@ -56,7 +57,7 @@ void IviSurface::ivi_surface_destroy_resource(Resource *resource) Q_UNUSED(resource); bool removed = m_iviApplication->m_iviSurfaces.removeOne(this); Q_ASSERT(removed); - qDebug() << "destriy"; + qDebug() << "destroy"; delete this; } diff --git a/tests/auto/client/shared/iviapplication.h b/tests/auto/client/shared/iviapplication.h index f92054ca..9f89295e 100644 --- a/tests/auto/client/shared/iviapplication.h +++ b/tests/auto/client/shared/iviapplication.h @@ -58,13 +58,15 @@ class IviSurface : public QObject, public QtWaylandServer::ivi_surface public: IviSurface(IviApplication *iviApplication, Surface *surface, uint32_t ivi_id, wl_client *client, int id, int version); + Surface *surface() const { return m_surface; } + void ivi_surface_destroy_resource(Resource *resource) override; void ivi_surface_destroy(Resource *resource) override; const uint m_iviId = 0; private: IviApplication *m_iviApplication; - + Surface *m_surface = nullptr; }; diff --git a/tests/auto/client/shared/mockcompositor.cpp b/tests/auto/client/shared/mockcompositor.cpp index 63134db5..d3742e09 100644 --- a/tests/auto/client/shared/mockcompositor.cpp +++ b/tests/auto/client/shared/mockcompositor.cpp @@ -79,6 +79,27 @@ DefaultCompositor::DefaultCompositor(CompositorType t) 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() { warnIfNotLockedByThread(Q_FUNC_INFO); @@ -98,6 +119,23 @@ void DefaultCompositor::xdgPingAndWaitForPong() 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) : DefaultCompositor(t) { diff --git a/tests/auto/client/shared/mockcompositor.h b/tests/auto/client/shared/mockcompositor.h index 7f3c0e31..89074b3a 100644 --- a/tests/auto/client/shared/mockcompositor.h +++ b/tests/auto/client/shared/mockcompositor.h @@ -58,7 +58,7 @@ public: explicit DefaultCompositor(CompositorType t = CompositorType::Default); // Convenience functions 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); } WlShellSurface *wlShellSurface(int i = 0) { return get<WlShell>()->m_wlShellSurfaces.value(i, nullptr); } Surface *wlSurface(int i = 0); @@ -71,8 +71,12 @@ public: Keyboard *keyboard() { auto *seat = get<Seat>(); Q_ASSERT(seat); return seat->m_keyboard; } FullScreenShellV1 *fullScreenShellV1() {return get<FullScreenShellV1>();}; IviSurface *iviSurface(int i = 0) { return get<IviApplication>()->m_iviSurfaces.value(i, nullptr); } + uint sendXdgShellPing(); void xdgPingAndWaitForPong(); + + void sendShellSurfaceConfigure(Surface *surface); + // Things that can be changed run-time without confusing the client (i.e. don't require separate tests) struct Config { bool autoEnter = true; |