Commit a295db01 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

autotests: Make mapping between KWin::Output and wl_output more robust

Use wl_output.name to find the wl_output for the given server side
output. This way the order in which wl_output globals are announced
won't matter.
parent 64800e72
Pipeline #227874 passed with stage
in 17 minutes and 41 seconds
......@@ -571,6 +571,7 @@ KWayland::Client::AppMenuManager *waylandAppMenuManager();
WaylandOutputManagementV2 *waylandOutputManagementV2();
KWayland::Client::TextInputManager *waylandTextInputManager();
QVector<KWayland::Client::Output *> waylandOutputs();
KWayland::Client::Output *waylandOutput(const QString &name);
QVector<WaylandOutputDeviceV2 *> waylandOutputDevicesV2();
bool waitForWaylandSurface(Window *window);
......
......@@ -120,27 +120,31 @@ void ScreenChangesTest::testScreenAddRemove()
QSignalSpy o1ChangedSpy(o1.get(), &KWayland::Client::Output::changed);
QVERIFY(o1ChangedSpy.isValid());
QVERIFY(o1ChangedSpy.wait());
QCOMPARE(o1->geometry(), geometries.at(0));
KWin::Output *serverOutput1 = kwinApp()->platform()->findOutput(o1->name()); // use wl_output.name to find the compositor side output
QCOMPARE(o1->globalPosition(), serverOutput1->geometry().topLeft());
QCOMPARE(o1->pixelSize(), serverOutput1->modeSize());
std::unique_ptr<KWayland::Client::Output> o2(registry.createOutput(outputAnnouncedSpy.last().first().value<quint32>(), outputAnnouncedSpy.last().last().value<quint32>()));
QVERIFY(o2->isValid());
QSignalSpy o2ChangedSpy(o2.get(), &KWayland::Client::Output::changed);
QVERIFY(o2ChangedSpy.isValid());
QVERIFY(o2ChangedSpy.wait());
QCOMPARE(o2->geometry(), geometries.at(1));
KWin::Output *serverOutput2 = kwinApp()->platform()->findOutput(o2->name()); // use wl_output.name to find the compositor side output
QCOMPARE(o2->globalPosition(), serverOutput2->geometry().topLeft());
QCOMPARE(o2->pixelSize(), serverOutput2->modeSize());
// and check XDGOutput is synced
std::unique_ptr<XdgOutput> xdgO1(xdgOutputManager->getXdgOutput(o1.get()));
QSignalSpy xdgO1ChangedSpy(xdgO1.get(), &XdgOutput::changed);
QVERIFY(xdgO1ChangedSpy.isValid());
QVERIFY(xdgO1ChangedSpy.wait());
QCOMPARE(xdgO1->logicalPosition(), geometries.at(0).topLeft());
QCOMPARE(xdgO1->logicalSize(), geometries.at(0).size());
QCOMPARE(xdgO1->logicalPosition(), serverOutput1->geometry().topLeft());
QCOMPARE(xdgO1->logicalSize(), serverOutput1->geometry().size());
std::unique_ptr<XdgOutput> xdgO2(xdgOutputManager->getXdgOutput(o2.get()));
QSignalSpy xdgO2ChangedSpy(xdgO2.get(), &XdgOutput::changed);
QVERIFY(xdgO2ChangedSpy.isValid());
QVERIFY(xdgO2ChangedSpy.wait());
QCOMPARE(xdgO2->logicalPosition(), geometries.at(1).topLeft());
QCOMPARE(xdgO2->logicalSize(), geometries.at(1).size());
QCOMPARE(xdgO2->logicalPosition(), serverOutput2->geometry().topLeft());
QCOMPARE(xdgO2->logicalSize(), serverOutput2->geometry().size());
QVERIFY(xdgO1->name().startsWith("Virtual-"));
QVERIFY(xdgO1->name() != xdgO2->name());
......
......@@ -640,6 +640,16 @@ QVector<KWayland::Client::Output *> waylandOutputs()
return s_waylandConnection.outputs;
}
KWayland::Client::Output *waylandOutput(const QString &name)
{
for (KWayland::Client::Output *output : std::as_const(s_waylandConnection.outputs)) {
if (output->name() == name) {
return output;
}
}
return nullptr;
}
QVector<KWin::Test::WaylandOutputDeviceV2 *> waylandOutputDevicesV2()
{
return s_waylandConnection.outputDevicesV2;
......
......@@ -561,7 +561,7 @@ void TestXdgShellWindow::testFullscreenMultipleOutputs()
// this test verifies that kwin will place fullscreen windows in the outputs its instructed to
const auto outputs = workspace()->outputs();
for (int i = 0; i < outputs.count(); ++i) {
for (KWin::Output *output : outputs) {
Test::XdgToplevel::States states;
std::unique_ptr<KWayland::Client::Surface> surface = Test::createSurface();
......@@ -590,10 +590,10 @@ void TestXdgShellWindow::testFullscreenMultipleOutputs()
QVERIFY(states.testFlag(Test::XdgToplevel::State::Activated));
// Ask the compositor to show the window in full screen mode.
shellSurface->set_fullscreen(*Test::waylandOutputs()[i]);
shellSurface->set_fullscreen(*Test::waylandOutput(output->name()));
QVERIFY(surfaceConfigureRequestedSpy.wait());
QCOMPARE(surfaceConfigureRequestedSpy.count(), 2);
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), outputs[i]->geometry().size());
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), output->geometry().size());
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
Test::render(surface.get(), toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), Qt::red);
......@@ -605,7 +605,7 @@ void TestXdgShellWindow::testFullscreenMultipleOutputs()
QVERIFY(window->isFullScreen());
QCOMPARE(window->frameGeometry(), outputs[i]->geometry());
QCOMPARE(window->frameGeometry(), output->geometry());
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment