diff --git a/src/wayland/autotests/client/test_wayland_output.cpp b/src/wayland/autotests/client/test_wayland_output.cpp index b558c863bc..b41d22d5cb 100644 --- a/src/wayland/autotests/client/test_wayland_output.cpp +++ b/src/wayland/autotests/client/test_wayland_output.cpp @@ -75,9 +75,9 @@ void TestWaylandOutput::init() QVERIFY(m_display->isRunning()); m_serverOutput = m_display->createOutput(this); - m_serverOutput->addMode(QSize(800, 600)); + m_serverOutput->addMode(QSize(800, 600), OutputInterface::ModeFlags(OutputInterface::ModeFlag::Preferred)); m_serverOutput->addMode(QSize(1024, 768)); - m_serverOutput->addMode(QSize(1280, 1024)); + m_serverOutput->addMode(QSize(1280, 1024), OutputInterface::ModeFlags(), 90000); m_serverOutput->setCurrentMode(QSize(1024, 768)); m_serverOutput->create(); @@ -161,6 +161,7 @@ void TestWaylandOutput::testRegistry() void TestWaylandOutput::testModeChanges() { + using namespace KWayland::Client; KWayland::Client::Registry registry; QSignalSpy announced(®istry, SIGNAL(outputAnnounced(quint32,quint32))); registry.create(m_connection->display()); @@ -172,22 +173,81 @@ void TestWaylandOutput::testModeChanges() KWayland::Client::Output output; QSignalSpy outputChanged(&output, SIGNAL(changed())); QVERIFY(outputChanged.isValid()); + QSignalSpy modeAddedSpy(&output, SIGNAL(modeAdded(KWayland::Client::Output::Mode))); + QVERIFY(modeAddedSpy.isValid()); output.setup(registry.bindOutput(announced.first().first().value(), announced.first().last().value())); wl_display_flush(m_connection->display()); QVERIFY(outputChanged.wait()); + QCOMPARE(modeAddedSpy.count(), 3); + QCOMPARE(modeAddedSpy.at(0).first().value().size, QSize(800, 600)); + QCOMPARE(modeAddedSpy.at(0).first().value().refreshRate, 60000); + QCOMPARE(modeAddedSpy.at(0).first().value().flags, Output::Mode::Flags(Output::Mode::Flag::Preferred)); + QCOMPARE(modeAddedSpy.at(0).first().value().output, QPointer(&output)); + QCOMPARE(modeAddedSpy.at(1).first().value().size, QSize(1280, 1024)); + QCOMPARE(modeAddedSpy.at(1).first().value().refreshRate, 90000); + QCOMPARE(modeAddedSpy.at(1).first().value().flags, Output::Mode::Flags(Output::Mode::Flag::None)); + QCOMPARE(modeAddedSpy.at(1).first().value().output, QPointer(&output)); + QCOMPARE(modeAddedSpy.at(2).first().value().size, QSize(1024, 768)); + QCOMPARE(modeAddedSpy.at(2).first().value().refreshRate, 60000); + QCOMPARE(modeAddedSpy.at(2).first().value().flags, Output::Mode::Flags(Output::Mode::Flag::Current)); + QCOMPARE(modeAddedSpy.at(2).first().value().output, QPointer(&output)); + const QList &modes = output.modes(); + QCOMPARE(modes.size(), 3); + QCOMPARE(modes.at(0), modeAddedSpy.at(0).first().value()); + QCOMPARE(modes.at(1), modeAddedSpy.at(1).first().value()); + QCOMPARE(modes.at(2), modeAddedSpy.at(2).first().value()); QCOMPARE(output.pixelSize(), QSize(1024, 768)); // change the current mode outputChanged.clear(); + QSignalSpy modeChangedSpy(&output, SIGNAL(modeChanged(KWayland::Client::Output::Mode))); + QVERIFY(modeChangedSpy.isValid()); m_serverOutput->setCurrentMode(QSize(800, 600)); - QVERIFY(outputChanged.wait()); + QVERIFY(modeChangedSpy.wait()); + if (modeChangedSpy.size() == 1) { + QVERIFY(modeChangedSpy.wait()); + } + QCOMPARE(modeChangedSpy.size(), 2); + // the one which lost the current flag + QCOMPARE(modeChangedSpy.first().first().value().size, QSize(1024, 768)); + QCOMPARE(modeChangedSpy.first().first().value().refreshRate, 60000); + QCOMPARE(modeChangedSpy.first().first().value().flags, Output::Mode::Flags()); + // the one which got the current flag + QCOMPARE(modeChangedSpy.last().first().value().size, QSize(800, 600)); + QCOMPARE(modeChangedSpy.last().first().value().refreshRate, 60000); + QCOMPARE(modeChangedSpy.last().first().value().flags, Output::Mode::Flags(Output::Mode::Flag::Current | Output::Mode::Flag::Preferred)); + QVERIFY(!outputChanged.isEmpty()); QCOMPARE(output.pixelSize(), QSize(800, 600)); + const QList &modes2 = output.modes(); + QCOMPARE(modes2.at(0).size, QSize(1280, 1024)); + QCOMPARE(modes2.at(0).refreshRate, 90000); + QCOMPARE(modes2.at(0).flags, Output::Mode::Flag::None); + QCOMPARE(modes2.at(1).size, QSize(1024, 768)); + QCOMPARE(modes2.at(1).refreshRate, 60000); + QCOMPARE(modes2.at(1).flags, Output::Mode::Flag::None); + QCOMPARE(modes2.at(2).size, QSize(800, 600)); + QCOMPARE(modes2.at(2).refreshRate, 60000); + QCOMPARE(modes2.at(2).flags, Output::Mode::Flag::Current | Output::Mode::Flag::Preferred); // change once more outputChanged.clear(); - m_serverOutput->setCurrentMode(QSize(1280, 1024)); - QVERIFY(outputChanged.wait()); + modeChangedSpy.clear(); + m_serverOutput->setCurrentMode(QSize(1280, 1024), 90000); + QVERIFY(modeChangedSpy.wait()); + if (modeChangedSpy.size() == 1) { + QVERIFY(modeChangedSpy.wait()); + } + QCOMPARE(modeChangedSpy.size(), 2); + // the one which lost the current flag + QCOMPARE(modeChangedSpy.first().first().value().size, QSize(800, 600)); + QCOMPARE(modeChangedSpy.first().first().value().refreshRate, 60000); + QCOMPARE(modeChangedSpy.first().first().value().flags, Output::Mode::Flags(Output::Mode::Flag::Preferred)); + // the one which got the current flag + QCOMPARE(modeChangedSpy.last().first().value().size, QSize(1280, 1024)); + QCOMPARE(modeChangedSpy.last().first().value().refreshRate, 90000); + QCOMPARE(modeChangedSpy.last().first().value().flags, Output::Mode::Flags(Output::Mode::Flag::Current)); + QVERIFY(!outputChanged.isEmpty()); QCOMPARE(output.pixelSize(), QSize(1280, 1024)); }