summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2020-01-09 12:20:23 +0100
committerJohan Klokkhammer Helsing <johan.helsing@qt.io>2020-02-27 08:05:04 +0100
commitcd64af4b6d469169b0fe9f26f9fca247cda84a55 (patch)
tree18dce86115f7c992b83367442eda415463cc45e0
parent61df944332e37a0155a3b3afba87e96c3f23da33 (diff)
Client tests for xdg-output unstable v1 version 3
Change-Id: If6d7547c14dfaf06532a83ab2fbda4d0198837dc Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
-rw-r--r--tests/auto/client/shared/coreprotocol.cpp8
-rw-r--r--tests/auto/client/shared/coreprotocol.h1
-rw-r--r--tests/auto/client/shared/xdgoutputv1.cpp24
-rw-r--r--tests/auto/client/shared/xdgoutputv1.h19
-rw-r--r--tests/auto/client/xdgoutput/tst_xdgoutput.cpp45
5 files changed, 83 insertions, 14 deletions
diff --git a/tests/auto/client/shared/coreprotocol.cpp b/tests/auto/client/shared/coreprotocol.cpp
index b0be2cb4e..0d9885216 100644
--- a/tests/auto/client/shared/coreprotocol.cpp
+++ b/tests/auto/client/shared/coreprotocol.cpp
@@ -158,6 +158,14 @@ void Output::sendScale(Resource *resource)
wl_output::send_scale(resource->handle, m_data.scale);
}
+void Output::sendDone(wl_client *client)
+{
+ Q_ASSERT(m_version >= WL_OUTPUT_DONE_SINCE_VERSION);
+ auto resources = resourceMap().values(client);
+ for (auto *r : resources)
+ wl_output::send_done(r->handle);
+}
+
void Output::sendDone()
{
Q_ASSERT(m_version >= WL_OUTPUT_DONE_SINCE_VERSION);
diff --git a/tests/auto/client/shared/coreprotocol.h b/tests/auto/client/shared/coreprotocol.h
index a12d22d36..8d5e2d66d 100644
--- a/tests/auto/client/shared/coreprotocol.h
+++ b/tests/auto/client/shared/coreprotocol.h
@@ -245,6 +245,7 @@ public:
void sendScale(int factor);
void sendScale(Resource *resource); // Sends current scale to only one client
+ void sendDone(wl_client *client);
void sendDone();
int scale() const { return m_data.scale; }
diff --git a/tests/auto/client/shared/xdgoutputv1.cpp b/tests/auto/client/shared/xdgoutputv1.cpp
index 21bfdaca5..2b491d2ee 100644
--- a/tests/auto/client/shared/xdgoutputv1.cpp
+++ b/tests/auto/client/shared/xdgoutputv1.cpp
@@ -32,4 +32,28 @@ namespace MockCompositor {
int XdgOutputV1::s_nextId = 1;
+void XdgOutputV1::sendLogicalSize(const QSize &size)
+{
+ m_logicalGeometry.setSize(size);
+ for (auto *resource : resourceMap())
+ zxdg_output_v1::send_logical_size(resource->handle, size.width(), size.height());
+}
+
+void XdgOutputV1::addResource(wl_client *client, int id, int version)
+{
+ auto *resource = add(client, id, version)->handle;
+ zxdg_output_v1::send_logical_size(resource, m_logicalGeometry.width(), m_logicalGeometry.height());
+ send_logical_position(resource, m_logicalGeometry.x(), m_logicalGeometry.y());
+ if (version >= ZXDG_OUTPUT_V1_NAME_SINCE_VERSION)
+ send_name(resource, m_name);
+ if (version >= ZXDG_OUTPUT_V1_DESCRIPTION_SINCE_VERSION)
+ send_description(resource, m_description);
+
+ if (version < 3) // zxdg_output_v1.done has been deprecated
+ zxdg_output_v1::send_done(resource);
+ else {
+ m_output->sendDone(client);
+ }
+}
+
} // namespace MockCompositor
diff --git a/tests/auto/client/shared/xdgoutputv1.h b/tests/auto/client/shared/xdgoutputv1.h
index e37b01e64..85b134500 100644
--- a/tests/auto/client/shared/xdgoutputv1.h
+++ b/tests/auto/client/shared/xdgoutputv1.h
@@ -44,17 +44,12 @@ public:
, m_name(QString("WL-%1").arg(s_nextId++))
{}
- void addResource(wl_client *client, int id, int version)
- {
- auto *resource = add(client, id, version)->handle;
- send_logical_size(resource, m_logicalGeometry.width(), m_logicalGeometry.height());
- send_logical_position(resource, m_logicalGeometry.x(), m_logicalGeometry.y());
- if (version >= ZXDG_OUTPUT_V1_NAME_SINCE_VERSION)
- send_name(resource, m_name);
- if (version >= ZXDG_OUTPUT_V1_DESCRIPTION_SINCE_VERSION)
- send_description(resource, m_description);
- send_done(resource);
- }
+ void send_logical_size(int32_t width, int32_t height) = delete;
+ void sendLogicalSize(const QSize &size);
+
+ void send_done() = delete; // zxdg_output_v1.done has been deprecated (in protocol version 3)
+
+ void addResource(wl_client *client, int id, int version);
Output *m_output = nullptr;
QRect m_logicalGeometry;
QString m_name;
@@ -66,7 +61,7 @@ class XdgOutputManagerV1 : public Global, public QtWaylandServer::zxdg_output_ma
{
Q_OBJECT
public:
- explicit XdgOutputManagerV1(CoreCompositor *compositor, int version = 2)
+ explicit XdgOutputManagerV1(CoreCompositor *compositor, int version = 3)
: QtWaylandServer::zxdg_output_manager_v1(compositor->m_display, version)
, m_version(version)
{}
diff --git a/tests/auto/client/xdgoutput/tst_xdgoutput.cpp b/tests/auto/client/xdgoutput/tst_xdgoutput.cpp
index 2f28d1fe6..804296081 100644
--- a/tests/auto/client/xdgoutput/tst_xdgoutput.cpp
+++ b/tests/auto/client/xdgoutput/tst_xdgoutput.cpp
@@ -40,7 +40,7 @@ public:
explicit XdgOutputV1Compositor()
{
exec([this] {
- int version = 2; // version 2 of of unstable-v1
+ int version = 3; // version 3 of of unstable-v1
add<XdgOutputManagerV1>(version);
});
}
@@ -54,11 +54,13 @@ private slots:
void cleanup();
void primaryScreen();
void overrideGeometry();
+ void changeGeometry();
};
void tst_xdgoutput::cleanup()
{
QCOMPOSITOR_COMPARE(getAll<Output>().size(), 1); // Only the default output should be left
+ QTRY_COMPARE(QGuiApplication::screens().size(), 1);
QTRY_VERIFY2(isClean(), qPrintable(dirtyMessage()));
}
@@ -68,7 +70,8 @@ void tst_xdgoutput::primaryScreen()
QCOMPOSITOR_TRY_COMPARE(get<XdgOutputManagerV1>()->resourceMap().size(), 1);
exec([=] {
auto *resource = xdgOutput()->resourceMap().value(client());
- QCOMPARE(resource->version(), 2);
+ QCOMPARE(resource->version(), 3);
+ QCOMPARE(xdgOutput()->m_logicalGeometry.size(), QSize(1920, 1080));
});
auto *s = QGuiApplication::primaryScreen();
QTRY_COMPARE(s->size(), QSize(1920, 1080));
@@ -93,5 +96,43 @@ void tst_xdgoutput::overrideGeometry()
exec([=] { remove(output(1)); });
}
+void tst_xdgoutput::changeGeometry()
+{
+ auto *xdgOutput = exec([=] {
+ auto *output = add<Output>();
+ auto *xdgOutput = get<XdgOutputManagerV1>()->getXdgOutput(output);
+ xdgOutput->m_logicalGeometry = QRect(10, 20, 800, 1200);
+ return xdgOutput;
+ });
+
+ QTRY_COMPARE(QGuiApplication::screens().size(), 2);
+ auto *screen = QGuiApplication::screens()[1];
+ QTRY_COMPARE(screen->size(), QSize(800, 1200));
+
+ exec([=] {
+ xdgOutput->sendLogicalSize(QSize(1024, 768));
+ });
+
+ // Now we want to check that the client doesn't apply the size immediately, but waits for the
+ // done event. If we TRY_COMPARE immediately, we risk that the client just hasn't handled the
+ // logical_size request yet, so we add a screen and verify it on the client side just to give
+ // the client a chance to mess up.
+ exec([=] { add<Output>(); });
+ QTRY_COMPARE(QGuiApplication::screens().size(), 3);
+ exec([=] { remove(output(2)); });
+
+ // The logical_size event should have been handled by now, but state should not have been applied yet.
+ QTRY_COMPARE(screen->size(), QSize(800, 1200));
+
+ exec([=] {
+ xdgOutput->m_output->sendDone();
+ });
+
+ // Finally, the size should change
+ QTRY_COMPARE(screen->size(), QSize(1024, 768));
+
+ exec([=] { remove(output(1)); });
+}
+
QCOMPOSITOR_TEST_MAIN(tst_xdgoutput)
#include "tst_xdgoutput.moc"