2020-03-15 15:19:28 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
2014-08-19 14:08:02 +00:00
|
|
|
|
2020-03-15 15:19:28 +00:00
|
|
|
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
|
|
*/
|
2014-08-19 14:08:02 +00:00
|
|
|
// Qt
|
2018-11-06 06:22:36 +00:00
|
|
|
#include <QtTest>
|
2014-08-19 14:08:02 +00:00
|
|
|
// KWin
|
2020-04-29 13:59:23 +00:00
|
|
|
#include "KWayland/Client/connection_thread.h"
|
|
|
|
#include "KWayland/Client/event_queue.h"
|
|
|
|
#include "KWayland/Client/dpms.h"
|
|
|
|
#include "KWayland/Client/output.h"
|
|
|
|
#include "KWayland/Client/registry.h"
|
2014-09-17 12:35:33 +00:00
|
|
|
#include "../../src/server/display.h"
|
2015-09-01 12:02:38 +00:00
|
|
|
#include "../../src/server/dpms_interface.h"
|
2014-09-17 12:35:33 +00:00
|
|
|
#include "../../src/server/output_interface.h"
|
2014-08-19 14:08:02 +00:00
|
|
|
// Wayland
|
|
|
|
#include <wayland-client-protocol.h>
|
|
|
|
|
|
|
|
class TestWaylandOutput : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit TestWaylandOutput(QObject *parent = nullptr);
|
|
|
|
private Q_SLOTS:
|
|
|
|
void init();
|
|
|
|
void cleanup();
|
|
|
|
|
|
|
|
void testRegistry();
|
2021-04-04 17:05:10 +00:00
|
|
|
void testModeChange();
|
2014-08-26 14:07:39 +00:00
|
|
|
void testScaleChange();
|
2014-08-19 14:08:02 +00:00
|
|
|
|
2014-08-26 14:07:39 +00:00
|
|
|
void testSubPixel_data();
|
|
|
|
void testSubPixel();
|
|
|
|
|
|
|
|
void testTransform_data();
|
|
|
|
void testTransform();
|
2014-08-19 14:08:02 +00:00
|
|
|
|
2015-09-01 12:02:38 +00:00
|
|
|
void testDpms_data();
|
|
|
|
void testDpms();
|
|
|
|
|
2016-04-08 09:42:51 +00:00
|
|
|
void testDpmsRequestMode_data();
|
|
|
|
void testDpmsRequestMode();
|
|
|
|
|
2014-08-19 14:08:02 +00:00
|
|
|
private:
|
2020-04-29 14:56:38 +00:00
|
|
|
KWaylandServer::Display *m_display;
|
|
|
|
KWaylandServer::OutputInterface *m_serverOutput;
|
2014-09-17 14:17:26 +00:00
|
|
|
KWayland::Client::ConnectionThread *m_connection;
|
2015-05-12 11:16:57 +00:00
|
|
|
KWayland::Client::EventQueue *m_queue;
|
2014-08-26 14:07:39 +00:00
|
|
|
QThread *m_thread;
|
2014-08-19 14:08:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const QString s_socketName = QStringLiteral("kwin-test-wayland-output-0");
|
|
|
|
|
|
|
|
TestWaylandOutput::TestWaylandOutput(QObject *parent)
|
|
|
|
: QObject(parent)
|
2014-08-26 14:07:39 +00:00
|
|
|
, m_display(nullptr)
|
|
|
|
, m_serverOutput(nullptr)
|
|
|
|
, m_connection(nullptr)
|
|
|
|
, m_thread(nullptr)
|
2014-08-19 14:08:02 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestWaylandOutput::init()
|
|
|
|
{
|
2020-04-29 14:56:38 +00:00
|
|
|
using namespace KWaylandServer;
|
2014-08-26 14:07:39 +00:00
|
|
|
delete m_display;
|
|
|
|
m_display = new Display(this);
|
2020-10-19 15:52:56 +00:00
|
|
|
m_display->addSocketName(s_socketName);
|
2014-08-26 14:07:39 +00:00
|
|
|
m_display->start();
|
|
|
|
QVERIFY(m_display->isRunning());
|
|
|
|
|
2020-12-09 20:13:19 +00:00
|
|
|
m_serverOutput = new OutputInterface(m_display, this);
|
2016-06-13 17:19:06 +00:00
|
|
|
QCOMPARE(m_serverOutput->pixelSize(), QSize());
|
|
|
|
QCOMPARE(m_serverOutput->refreshRate(), 60000);
|
2021-04-04 17:05:10 +00:00
|
|
|
m_serverOutput->setMode(QSize(1024, 768));
|
2016-06-13 17:19:06 +00:00
|
|
|
QCOMPARE(m_serverOutput->pixelSize(), QSize(1024, 768));
|
|
|
|
QCOMPARE(m_serverOutput->refreshRate(), 60000);
|
2015-09-01 12:02:38 +00:00
|
|
|
QCOMPARE(m_serverOutput->isDpmsSupported(), false);
|
2020-05-19 13:11:27 +00:00
|
|
|
QCOMPARE(m_serverOutput->dpmsMode(), OutputInterface::DpmsMode::Off);
|
2014-08-26 14:07:39 +00:00
|
|
|
|
|
|
|
// setup connection
|
2014-09-17 14:17:26 +00:00
|
|
|
m_connection = new KWayland::Client::ConnectionThread;
|
2021-02-25 13:48:11 +00:00
|
|
|
QSignalSpy connectedSpy(m_connection, &KWayland::Client::ConnectionThread::connected);
|
2014-08-26 14:07:39 +00:00
|
|
|
m_connection->setSocketName(s_socketName);
|
|
|
|
|
|
|
|
m_thread = new QThread(this);
|
|
|
|
m_connection->moveToThread(m_thread);
|
|
|
|
m_thread->start();
|
|
|
|
|
|
|
|
m_connection->initConnection();
|
|
|
|
QVERIFY(connectedSpy.wait());
|
2015-05-12 11:16:57 +00:00
|
|
|
|
|
|
|
m_queue = new KWayland::Client::EventQueue(this);
|
|
|
|
QVERIFY(!m_queue->isValid());
|
|
|
|
m_queue->setup(m_connection);
|
|
|
|
QVERIFY(m_queue->isValid());
|
2014-08-19 14:08:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestWaylandOutput::cleanup()
|
|
|
|
{
|
2015-05-12 11:16:57 +00:00
|
|
|
if (m_queue) {
|
|
|
|
delete m_queue;
|
|
|
|
m_queue = nullptr;
|
|
|
|
}
|
2014-08-26 14:07:39 +00:00
|
|
|
if (m_thread) {
|
|
|
|
m_thread->quit();
|
|
|
|
m_thread->wait();
|
|
|
|
delete m_thread;
|
|
|
|
m_thread = nullptr;
|
|
|
|
}
|
|
|
|
delete m_connection;
|
|
|
|
m_connection = nullptr;
|
|
|
|
|
|
|
|
delete m_display;
|
|
|
|
m_display = nullptr;
|
2020-10-30 13:36:24 +00:00
|
|
|
|
|
|
|
// these are the children of the display
|
|
|
|
m_serverOutput = nullptr;
|
2014-08-19 14:08:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestWaylandOutput::testRegistry()
|
|
|
|
{
|
2020-04-29 14:56:38 +00:00
|
|
|
QSignalSpy globalPositionChangedSpy(m_serverOutput, &KWaylandServer::OutputInterface::globalPositionChanged);
|
2016-06-13 17:19:06 +00:00
|
|
|
QVERIFY(globalPositionChangedSpy.isValid());
|
|
|
|
QCOMPARE(m_serverOutput->globalPosition(), QPoint(0, 0));
|
2014-08-26 14:07:39 +00:00
|
|
|
m_serverOutput->setGlobalPosition(QPoint(100, 50));
|
2016-06-13 17:19:06 +00:00
|
|
|
QCOMPARE(m_serverOutput->globalPosition(), QPoint(100, 50));
|
|
|
|
QCOMPARE(globalPositionChangedSpy.count(), 1);
|
|
|
|
// changing again should not trigger signal
|
|
|
|
m_serverOutput->setGlobalPosition(QPoint(100, 50));
|
|
|
|
QCOMPARE(globalPositionChangedSpy.count(), 1);
|
|
|
|
|
2020-04-29 14:56:38 +00:00
|
|
|
QSignalSpy physicalSizeChangedSpy(m_serverOutput, &KWaylandServer::OutputInterface::physicalSizeChanged);
|
2016-06-13 17:19:06 +00:00
|
|
|
QVERIFY(physicalSizeChangedSpy.isValid());
|
|
|
|
QCOMPARE(m_serverOutput->physicalSize(), QSize());
|
2014-08-26 14:07:39 +00:00
|
|
|
m_serverOutput->setPhysicalSize(QSize(200, 100));
|
2016-06-13 17:19:06 +00:00
|
|
|
QCOMPARE(m_serverOutput->physicalSize(), QSize(200, 100));
|
|
|
|
QCOMPARE(physicalSizeChangedSpy.count(), 1);
|
|
|
|
// changing again should not trigger signal
|
|
|
|
m_serverOutput->setPhysicalSize(QSize(200, 100));
|
|
|
|
QCOMPARE(physicalSizeChangedSpy.count(), 1);
|
2021-03-18 01:14:44 +00:00
|
|
|
m_serverOutput->done();
|
2014-08-19 14:08:02 +00:00
|
|
|
|
2014-09-17 14:17:26 +00:00
|
|
|
KWayland::Client::Registry registry;
|
2021-02-25 13:48:11 +00:00
|
|
|
QSignalSpy announced(®istry, &KWayland::Client::Registry::outputAnnounced);
|
2014-08-26 14:07:39 +00:00
|
|
|
registry.create(m_connection->display());
|
2014-08-19 14:08:02 +00:00
|
|
|
QVERIFY(registry.isValid());
|
|
|
|
registry.setup();
|
2014-08-26 14:07:39 +00:00
|
|
|
wl_display_flush(m_connection->display());
|
2014-08-19 14:08:02 +00:00
|
|
|
QVERIFY(announced.wait());
|
|
|
|
|
2014-09-17 14:17:26 +00:00
|
|
|
KWayland::Client::Output output;
|
2014-08-19 14:08:02 +00:00
|
|
|
QVERIFY(!output.isValid());
|
|
|
|
QCOMPARE(output.geometry(), QRect());
|
|
|
|
QCOMPARE(output.globalPosition(), QPoint());
|
|
|
|
QCOMPARE(output.manufacturer(), QString());
|
|
|
|
QCOMPARE(output.model(), QString());
|
|
|
|
QCOMPARE(output.physicalSize(), QSize());
|
|
|
|
QCOMPARE(output.pixelSize(), QSize());
|
|
|
|
QCOMPARE(output.refreshRate(), 0);
|
|
|
|
QCOMPARE(output.scale(), 1);
|
2014-09-17 14:17:26 +00:00
|
|
|
QCOMPARE(output.subPixel(), KWayland::Client::Output::SubPixel::Unknown);
|
|
|
|
QCOMPARE(output.transform(), KWayland::Client::Output::Transform::Normal);
|
2014-08-19 14:08:02 +00:00
|
|
|
|
2021-02-25 13:48:11 +00:00
|
|
|
QSignalSpy outputChanged(&output, &KWayland::Client::Output::changed);
|
2014-08-19 14:08:02 +00:00
|
|
|
QVERIFY(outputChanged.isValid());
|
|
|
|
|
2016-08-22 08:02:28 +00:00
|
|
|
auto o = registry.bindOutput(announced.first().first().value<quint32>(), announced.first().last().value<quint32>());
|
|
|
|
QVERIFY(!KWayland::Client::Output::get(o));
|
|
|
|
output.setup(o);
|
|
|
|
QCOMPARE(KWayland::Client::Output::get(o), &output);
|
2014-08-26 14:07:39 +00:00
|
|
|
wl_display_flush(m_connection->display());
|
2014-08-19 14:08:02 +00:00
|
|
|
QVERIFY(outputChanged.wait());
|
|
|
|
|
2014-08-26 14:07:39 +00:00
|
|
|
QCOMPARE(output.geometry(), QRect(100, 50, 1024, 768));
|
|
|
|
QCOMPARE(output.globalPosition(), QPoint(100, 50));
|
|
|
|
QCOMPARE(output.manufacturer(), QStringLiteral("org.kde.kwin"));
|
2014-08-19 14:08:02 +00:00
|
|
|
QCOMPARE(output.model(), QStringLiteral("none"));
|
2014-08-26 14:07:39 +00:00
|
|
|
QCOMPARE(output.physicalSize(), QSize(200, 100));
|
2014-08-19 14:08:02 +00:00
|
|
|
QCOMPARE(output.pixelSize(), QSize(1024, 768));
|
|
|
|
QCOMPARE(output.refreshRate(), 60000);
|
|
|
|
QCOMPARE(output.scale(), 1);
|
|
|
|
// for xwayland output it's unknown
|
2014-09-17 14:17:26 +00:00
|
|
|
QCOMPARE(output.subPixel(), KWayland::Client::Output::SubPixel::Unknown);
|
2014-08-19 14:08:02 +00:00
|
|
|
// for xwayland transform is normal
|
2014-09-17 14:17:26 +00:00
|
|
|
QCOMPARE(output.transform(), KWayland::Client::Output::Transform::Normal);
|
2014-08-19 14:08:02 +00:00
|
|
|
}
|
|
|
|
|
2021-04-04 17:05:10 +00:00
|
|
|
void TestWaylandOutput::testModeChange()
|
2014-08-26 14:07:39 +00:00
|
|
|
{
|
2014-09-23 13:56:13 +00:00
|
|
|
using namespace KWayland::Client;
|
2014-09-17 14:17:26 +00:00
|
|
|
KWayland::Client::Registry registry;
|
2021-02-25 13:48:11 +00:00
|
|
|
QSignalSpy announced(®istry, &KWayland::Client::Registry::outputAnnounced);
|
2015-05-12 11:16:57 +00:00
|
|
|
registry.setEventQueue(m_queue);
|
2014-08-26 14:07:39 +00:00
|
|
|
registry.create(m_connection->display());
|
|
|
|
QVERIFY(registry.isValid());
|
|
|
|
registry.setup();
|
|
|
|
wl_display_flush(m_connection->display());
|
|
|
|
QVERIFY(announced.wait());
|
|
|
|
|
2014-09-17 14:17:26 +00:00
|
|
|
KWayland::Client::Output output;
|
2021-02-25 13:48:11 +00:00
|
|
|
QSignalSpy outputChanged(&output, &KWayland::Client::Output::changed);
|
2014-08-26 14:07:39 +00:00
|
|
|
QVERIFY(outputChanged.isValid());
|
2021-02-25 13:48:11 +00:00
|
|
|
QSignalSpy modeAddedSpy(&output, &KWayland::Client::Output::modeAdded);
|
2014-09-23 13:56:13 +00:00
|
|
|
QVERIFY(modeAddedSpy.isValid());
|
2014-08-26 14:07:39 +00:00
|
|
|
output.setup(registry.bindOutput(announced.first().first().value<quint32>(), announced.first().last().value<quint32>()));
|
|
|
|
wl_display_flush(m_connection->display());
|
|
|
|
QVERIFY(outputChanged.wait());
|
2021-04-04 17:05:10 +00:00
|
|
|
QCOMPARE(modeAddedSpy.count(), 1);
|
|
|
|
QCOMPARE(modeAddedSpy.at(0).first().value<Output::Mode>().size, QSize(1024, 768));
|
2014-09-23 13:56:13 +00:00
|
|
|
QCOMPARE(modeAddedSpy.at(0).first().value<Output::Mode>().refreshRate, 60000);
|
2021-04-04 17:05:10 +00:00
|
|
|
QCOMPARE(modeAddedSpy.at(0).first().value<Output::Mode>().flags, Output::Mode::Flags(Output::Mode::Flag::Current));
|
2014-09-23 13:56:13 +00:00
|
|
|
QCOMPARE(modeAddedSpy.at(0).first().value<Output::Mode>().output, QPointer<Output>(&output));
|
2014-08-26 14:07:39 +00:00
|
|
|
QCOMPARE(output.pixelSize(), QSize(1024, 768));
|
2021-04-04 17:05:10 +00:00
|
|
|
QCOMPARE(output.refreshRate(), 60000);
|
2014-08-26 14:07:39 +00:00
|
|
|
|
|
|
|
// change once more
|
2021-04-04 17:05:10 +00:00
|
|
|
m_serverOutput->setMode(QSize(1280, 1024), 90000);
|
2016-06-13 17:19:06 +00:00
|
|
|
QCOMPARE(m_serverOutput->refreshRate(), 90000);
|
2021-03-18 01:14:44 +00:00
|
|
|
m_serverOutput->done();
|
2021-04-04 17:05:10 +00:00
|
|
|
QVERIFY(outputChanged.wait());
|
|
|
|
QCOMPARE(modeAddedSpy.count(), 2);
|
|
|
|
QCOMPARE(modeAddedSpy.at(1).first().value<Output::Mode>().size, QSize(1280, 1024));
|
|
|
|
QCOMPARE(modeAddedSpy.at(1).first().value<Output::Mode>().refreshRate, 90000);
|
|
|
|
QCOMPARE(modeAddedSpy.at(1).first().value<Output::Mode>().flags, Output::Mode::Flags(Output::Mode::Flag::Current));
|
|
|
|
QCOMPARE(modeAddedSpy.at(1).first().value<Output::Mode>().output, QPointer<Output>(&output));
|
2014-08-26 14:07:39 +00:00
|
|
|
QCOMPARE(output.pixelSize(), QSize(1280, 1024));
|
2021-04-04 17:05:10 +00:00
|
|
|
QCOMPARE(output.refreshRate(), 90000);
|
2014-08-26 14:07:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestWaylandOutput::testScaleChange()
|
|
|
|
{
|
2014-09-17 14:17:26 +00:00
|
|
|
KWayland::Client::Registry registry;
|
2021-02-25 13:48:11 +00:00
|
|
|
QSignalSpy announced(®istry, &KWayland::Client::Registry::outputAnnounced);
|
2014-08-26 14:07:39 +00:00
|
|
|
registry.create(m_connection->display());
|
|
|
|
QVERIFY(registry.isValid());
|
|
|
|
registry.setup();
|
|
|
|
wl_display_flush(m_connection->display());
|
|
|
|
QVERIFY(announced.wait());
|
|
|
|
|
2014-09-17 14:17:26 +00:00
|
|
|
KWayland::Client::Output output;
|
2021-02-25 13:48:11 +00:00
|
|
|
QSignalSpy outputChanged(&output, &KWayland::Client::Output::changed);
|
2014-08-26 14:07:39 +00:00
|
|
|
QVERIFY(outputChanged.isValid());
|
|
|
|
output.setup(registry.bindOutput(announced.first().first().value<quint32>(), announced.first().last().value<quint32>()));
|
|
|
|
wl_display_flush(m_connection->display());
|
|
|
|
QVERIFY(outputChanged.wait());
|
|
|
|
QCOMPARE(output.scale(), 1);
|
|
|
|
|
|
|
|
// change the scale
|
|
|
|
outputChanged.clear();
|
2016-06-13 17:19:06 +00:00
|
|
|
QCOMPARE(m_serverOutput->scale(), 1);
|
2020-04-29 14:56:38 +00:00
|
|
|
QSignalSpy serverScaleChanged(m_serverOutput, &KWaylandServer::OutputInterface::scaleChanged);
|
2016-06-13 17:19:06 +00:00
|
|
|
QVERIFY(serverScaleChanged.isValid());
|
2014-08-26 14:07:39 +00:00
|
|
|
m_serverOutput->setScale(2);
|
2016-06-13 17:19:06 +00:00
|
|
|
QCOMPARE(m_serverOutput->scale(), 2);
|
2021-03-18 01:14:44 +00:00
|
|
|
m_serverOutput->done();
|
2016-06-13 17:19:06 +00:00
|
|
|
QCOMPARE(serverScaleChanged.count(), 1);
|
2014-08-26 14:07:39 +00:00
|
|
|
QVERIFY(outputChanged.wait());
|
|
|
|
QCOMPARE(output.scale(), 2);
|
2016-06-13 17:19:06 +00:00
|
|
|
// changing to same value should not trigger
|
|
|
|
m_serverOutput->setScale(2);
|
|
|
|
QCOMPARE(serverScaleChanged.count(), 1);
|
|
|
|
QVERIFY(!outputChanged.wait(100));
|
2014-08-26 14:07:39 +00:00
|
|
|
|
|
|
|
// change once more
|
|
|
|
outputChanged.clear();
|
|
|
|
m_serverOutput->setScale(4);
|
2021-03-18 01:14:44 +00:00
|
|
|
m_serverOutput->done();
|
2014-08-26 14:07:39 +00:00
|
|
|
QVERIFY(outputChanged.wait());
|
|
|
|
QCOMPARE(output.scale(), 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestWaylandOutput::testSubPixel_data()
|
|
|
|
{
|
2014-09-17 14:17:26 +00:00
|
|
|
using namespace KWayland::Client;
|
2020-04-29 14:56:38 +00:00
|
|
|
using namespace KWaylandServer;
|
2014-09-17 14:17:26 +00:00
|
|
|
QTest::addColumn<KWayland::Client::Output::SubPixel>("expected");
|
2020-04-29 14:56:38 +00:00
|
|
|
QTest::addColumn<KWaylandServer::OutputInterface::SubPixel>("actual");
|
2014-08-26 14:07:39 +00:00
|
|
|
|
|
|
|
QTest::newRow("none") << Output::SubPixel::None << OutputInterface::SubPixel::None;
|
|
|
|
QTest::newRow("horizontal/rgb") << Output::SubPixel::HorizontalRGB << OutputInterface::SubPixel::HorizontalRGB;
|
|
|
|
QTest::newRow("horizontal/bgr") << Output::SubPixel::HorizontalBGR << OutputInterface::SubPixel::HorizontalBGR;
|
|
|
|
QTest::newRow("vertical/rgb") << Output::SubPixel::VerticalRGB << OutputInterface::SubPixel::VerticalRGB;
|
|
|
|
QTest::newRow("vertical/bgr") << Output::SubPixel::VerticalBGR << OutputInterface::SubPixel::VerticalBGR;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestWaylandOutput::testSubPixel()
|
|
|
|
{
|
2014-09-17 14:17:26 +00:00
|
|
|
using namespace KWayland::Client;
|
2020-04-29 14:56:38 +00:00
|
|
|
using namespace KWaylandServer;
|
2014-08-26 14:07:39 +00:00
|
|
|
QFETCH(OutputInterface::SubPixel, actual);
|
2016-06-13 17:19:06 +00:00
|
|
|
QCOMPARE(m_serverOutput->subPixel(), OutputInterface::SubPixel::Unknown);
|
|
|
|
QSignalSpy serverSubPixelChangedSpy(m_serverOutput, &OutputInterface::subPixelChanged);
|
|
|
|
QVERIFY(serverSubPixelChangedSpy.isValid());
|
2014-08-26 14:07:39 +00:00
|
|
|
m_serverOutput->setSubPixel(actual);
|
2016-06-13 17:19:06 +00:00
|
|
|
QCOMPARE(m_serverOutput->subPixel(), actual);
|
|
|
|
QCOMPARE(serverSubPixelChangedSpy.count(), 1);
|
|
|
|
// changing to same value should not trigger the signal
|
|
|
|
m_serverOutput->setSubPixel(actual);
|
|
|
|
QCOMPARE(serverSubPixelChangedSpy.count(), 1);
|
2014-08-26 14:07:39 +00:00
|
|
|
|
2014-09-17 14:17:26 +00:00
|
|
|
KWayland::Client::Registry registry;
|
2021-02-25 13:48:11 +00:00
|
|
|
QSignalSpy announced(®istry, &KWayland::Client::Registry::outputAnnounced);
|
2014-08-26 14:07:39 +00:00
|
|
|
registry.create(m_connection->display());
|
|
|
|
QVERIFY(registry.isValid());
|
|
|
|
registry.setup();
|
|
|
|
wl_display_flush(m_connection->display());
|
|
|
|
QVERIFY(announced.wait());
|
|
|
|
|
2014-09-17 14:17:26 +00:00
|
|
|
KWayland::Client::Output output;
|
2021-02-25 13:48:11 +00:00
|
|
|
QSignalSpy outputChanged(&output, &KWayland::Client::Output::changed);
|
2014-08-26 14:07:39 +00:00
|
|
|
QVERIFY(outputChanged.isValid());
|
|
|
|
output.setup(registry.bindOutput(announced.first().first().value<quint32>(), announced.first().last().value<quint32>()));
|
|
|
|
wl_display_flush(m_connection->display());
|
|
|
|
if (outputChanged.isEmpty()) {
|
|
|
|
QVERIFY(outputChanged.wait());
|
|
|
|
}
|
|
|
|
|
|
|
|
QTEST(output.subPixel(), "expected");
|
|
|
|
|
|
|
|
// change back to unknown
|
|
|
|
outputChanged.clear();
|
|
|
|
m_serverOutput->setSubPixel(OutputInterface::SubPixel::Unknown);
|
2016-06-13 17:19:06 +00:00
|
|
|
QCOMPARE(m_serverOutput->subPixel(), OutputInterface::SubPixel::Unknown);
|
2021-03-18 01:14:44 +00:00
|
|
|
m_serverOutput->done();
|
2016-06-13 17:19:06 +00:00
|
|
|
QCOMPARE(serverSubPixelChangedSpy.count(), 2);
|
2014-08-26 14:07:39 +00:00
|
|
|
if (outputChanged.isEmpty()) {
|
|
|
|
QVERIFY(outputChanged.wait());
|
|
|
|
}
|
|
|
|
QCOMPARE(output.subPixel(), Output::SubPixel::Unknown);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestWaylandOutput::testTransform_data()
|
|
|
|
{
|
2014-09-17 14:17:26 +00:00
|
|
|
using namespace KWayland::Client;
|
2020-04-29 14:56:38 +00:00
|
|
|
using namespace KWaylandServer;
|
2014-09-17 14:17:26 +00:00
|
|
|
QTest::addColumn<KWayland::Client::Output::Transform>("expected");
|
2020-04-29 14:56:38 +00:00
|
|
|
QTest::addColumn<KWaylandServer::OutputInterface::Transform>("actual");
|
2014-08-26 14:07:39 +00:00
|
|
|
|
|
|
|
QTest::newRow("90") << Output::Transform::Rotated90 << OutputInterface::Transform::Rotated90;
|
|
|
|
QTest::newRow("180") << Output::Transform::Rotated180 << OutputInterface::Transform::Rotated180;
|
|
|
|
QTest::newRow("270") << Output::Transform::Rotated270 << OutputInterface::Transform::Rotated270;
|
|
|
|
QTest::newRow("Flipped") << Output::Transform::Flipped << OutputInterface::Transform::Flipped;
|
|
|
|
QTest::newRow("Flipped 90") << Output::Transform::Flipped90 << OutputInterface::Transform::Flipped90;
|
|
|
|
QTest::newRow("Flipped 180") << Output::Transform::Flipped180 << OutputInterface::Transform::Flipped180;
|
|
|
|
QTest::newRow("Flipped 280") << Output::Transform::Flipped270 << OutputInterface::Transform::Flipped270;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestWaylandOutput::testTransform()
|
|
|
|
{
|
2014-09-17 14:17:26 +00:00
|
|
|
using namespace KWayland::Client;
|
2020-04-29 14:56:38 +00:00
|
|
|
using namespace KWaylandServer;
|
2014-08-26 14:07:39 +00:00
|
|
|
QFETCH(OutputInterface::Transform, actual);
|
2016-06-13 17:19:06 +00:00
|
|
|
QCOMPARE(m_serverOutput->transform(), OutputInterface::Transform::Normal);
|
|
|
|
QSignalSpy serverTransformChangedSpy(m_serverOutput, &OutputInterface::transformChanged);
|
|
|
|
QVERIFY(serverTransformChangedSpy.isValid());
|
|
|
|
m_serverOutput->setTransform(actual);
|
|
|
|
QCOMPARE(m_serverOutput->transform(), actual);
|
|
|
|
QCOMPARE(serverTransformChangedSpy.count(), 1);
|
|
|
|
// changing to same should not trigger signal
|
2014-08-26 14:07:39 +00:00
|
|
|
m_serverOutput->setTransform(actual);
|
2016-06-13 17:19:06 +00:00
|
|
|
QCOMPARE(serverTransformChangedSpy.count(), 1);
|
2014-08-26 14:07:39 +00:00
|
|
|
|
2014-09-17 14:17:26 +00:00
|
|
|
KWayland::Client::Registry registry;
|
2021-02-25 13:48:11 +00:00
|
|
|
QSignalSpy announced(®istry, &KWayland::Client::Registry::outputAnnounced);
|
2014-08-26 14:07:39 +00:00
|
|
|
registry.create(m_connection->display());
|
|
|
|
QVERIFY(registry.isValid());
|
|
|
|
registry.setup();
|
|
|
|
wl_display_flush(m_connection->display());
|
|
|
|
QVERIFY(announced.wait());
|
|
|
|
|
2014-09-19 08:42:44 +00:00
|
|
|
KWayland::Client::Output *output = registry.createOutput(announced.first().first().value<quint32>(), announced.first().last().value<quint32>(), ®istry);
|
2021-02-25 13:48:11 +00:00
|
|
|
QSignalSpy outputChanged(output, &KWayland::Client::Output::changed);
|
2014-08-26 14:07:39 +00:00
|
|
|
QVERIFY(outputChanged.isValid());
|
|
|
|
wl_display_flush(m_connection->display());
|
|
|
|
if (outputChanged.isEmpty()) {
|
|
|
|
QVERIFY(outputChanged.wait());
|
|
|
|
}
|
|
|
|
|
2014-09-19 08:42:44 +00:00
|
|
|
QTEST(output->transform(), "expected");
|
2014-08-26 14:07:39 +00:00
|
|
|
|
|
|
|
// change back to normal
|
|
|
|
outputChanged.clear();
|
|
|
|
m_serverOutput->setTransform(OutputInterface::Transform::Normal);
|
2016-06-13 17:19:06 +00:00
|
|
|
QCOMPARE(m_serverOutput->transform(), OutputInterface::Transform::Normal);
|
2021-03-18 01:14:44 +00:00
|
|
|
m_serverOutput->done();
|
2016-06-13 17:19:06 +00:00
|
|
|
QCOMPARE(serverTransformChangedSpy.count(), 2);
|
2014-08-26 14:07:39 +00:00
|
|
|
if (outputChanged.isEmpty()) {
|
|
|
|
QVERIFY(outputChanged.wait());
|
|
|
|
}
|
2014-09-19 08:42:44 +00:00
|
|
|
QCOMPARE(output->transform(), Output::Transform::Normal);
|
2014-08-26 14:07:39 +00:00
|
|
|
}
|
|
|
|
|
2015-09-01 12:02:38 +00:00
|
|
|
void TestWaylandOutput::testDpms_data()
|
|
|
|
{
|
|
|
|
using namespace KWayland::Client;
|
2020-04-29 14:56:38 +00:00
|
|
|
using namespace KWaylandServer;
|
2015-09-01 12:02:38 +00:00
|
|
|
|
|
|
|
QTest::addColumn<KWayland::Client::Dpms::Mode>("client");
|
2020-04-29 14:56:38 +00:00
|
|
|
QTest::addColumn<KWaylandServer::OutputInterface::DpmsMode>("server");
|
2015-09-01 12:02:38 +00:00
|
|
|
|
|
|
|
QTest::newRow("Standby") << Dpms::Mode::Standby << OutputInterface::DpmsMode::Standby;
|
|
|
|
QTest::newRow("Suspend") << Dpms::Mode::Suspend << OutputInterface::DpmsMode::Suspend;
|
2020-05-19 13:11:27 +00:00
|
|
|
QTest::newRow("On") << Dpms::Mode::On << OutputInterface::DpmsMode::On;
|
2015-09-01 12:02:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestWaylandOutput::testDpms()
|
|
|
|
{
|
|
|
|
using namespace KWayland::Client;
|
2020-04-29 14:56:38 +00:00
|
|
|
using namespace KWaylandServer;
|
2015-09-01 12:02:38 +00:00
|
|
|
|
2021-04-22 15:31:26 +00:00
|
|
|
DpmsManagerInterface iface(m_display);
|
2015-09-01 12:02:38 +00:00
|
|
|
|
|
|
|
// set Dpms on the Output
|
|
|
|
QSignalSpy serverDpmsSupportedChangedSpy(m_serverOutput, &OutputInterface::dpmsSupportedChanged);
|
|
|
|
QVERIFY(serverDpmsSupportedChangedSpy.isValid());
|
|
|
|
QCOMPARE(m_serverOutput->isDpmsSupported(), false);
|
|
|
|
m_serverOutput->setDpmsSupported(true);
|
|
|
|
QCOMPARE(serverDpmsSupportedChangedSpy.count(), 1);
|
|
|
|
QCOMPARE(m_serverOutput->isDpmsSupported(), true);
|
|
|
|
|
|
|
|
KWayland::Client::Registry registry;
|
|
|
|
registry.setEventQueue(m_queue);
|
|
|
|
QSignalSpy announced(®istry, &Registry::interfacesAnnounced);
|
|
|
|
QVERIFY(announced.isValid());
|
|
|
|
QSignalSpy dpmsAnnouncedSpy(®istry, &Registry::dpmsAnnounced);
|
|
|
|
QVERIFY(dpmsAnnouncedSpy.isValid());
|
|
|
|
registry.create(m_connection->display());
|
|
|
|
QVERIFY(registry.isValid());
|
|
|
|
registry.setup();
|
|
|
|
m_connection->flush();
|
|
|
|
QVERIFY(announced.wait());
|
|
|
|
QCOMPARE(dpmsAnnouncedSpy.count(), 1);
|
|
|
|
|
|
|
|
Output *output = registry.createOutput(registry.interface(Registry::Interface::Output).name, registry.interface(Registry::Interface::Output).version, ®istry);
|
|
|
|
|
|
|
|
DpmsManager *dpmsManager = registry.createDpmsManager(dpmsAnnouncedSpy.first().first().value<quint32>(), dpmsAnnouncedSpy.first().last().value<quint32>(), ®istry);
|
|
|
|
QVERIFY(dpmsManager->isValid());
|
|
|
|
|
|
|
|
Dpms *dpms = dpmsManager->getDpms(output, ®istry);
|
|
|
|
QSignalSpy clientDpmsSupportedChangedSpy(dpms, &Dpms::supportedChanged);
|
|
|
|
QVERIFY(clientDpmsSupportedChangedSpy.isValid());
|
|
|
|
QVERIFY(dpms->isValid());
|
|
|
|
QCOMPARE(dpms->isSupported(), false);
|
|
|
|
QCOMPARE(dpms->mode(), Dpms::Mode::On);
|
|
|
|
m_connection->flush();
|
|
|
|
QVERIFY(clientDpmsSupportedChangedSpy.wait());
|
|
|
|
QCOMPARE(clientDpmsSupportedChangedSpy.count(), 1);
|
|
|
|
QCOMPARE(dpms->isSupported(), true);
|
|
|
|
|
|
|
|
// and let's change to suspend
|
|
|
|
QSignalSpy serverDpmsModeChangedSpy(m_serverOutput, &OutputInterface::dpmsModeChanged);
|
|
|
|
QVERIFY(serverDpmsModeChangedSpy.isValid());
|
|
|
|
QSignalSpy clientDpmsModeChangedSpy(dpms, &Dpms::modeChanged);
|
|
|
|
QVERIFY(clientDpmsModeChangedSpy.isValid());
|
|
|
|
|
2020-05-19 13:11:27 +00:00
|
|
|
QCOMPARE(m_serverOutput->dpmsMode(), OutputInterface::DpmsMode::Off);
|
2015-09-01 12:02:38 +00:00
|
|
|
QFETCH(OutputInterface::DpmsMode, server);
|
|
|
|
m_serverOutput->setDpmsMode(server);
|
|
|
|
QCOMPARE(m_serverOutput->dpmsMode(), server);
|
|
|
|
QCOMPARE(serverDpmsModeChangedSpy.count(), 1);
|
|
|
|
|
|
|
|
QVERIFY(clientDpmsModeChangedSpy.wait());
|
|
|
|
QCOMPARE(clientDpmsModeChangedSpy.count(), 1);
|
|
|
|
QTEST(dpms->mode(), "client");
|
2016-04-08 09:42:51 +00:00
|
|
|
|
|
|
|
// test supported changed
|
|
|
|
QSignalSpy supportedChangedSpy(dpms, &Dpms::supportedChanged);
|
|
|
|
QVERIFY(supportedChangedSpy.isValid());
|
|
|
|
m_serverOutput->setDpmsSupported(false);
|
|
|
|
QVERIFY(supportedChangedSpy.wait());
|
|
|
|
QCOMPARE(supportedChangedSpy.count(), 1);
|
|
|
|
QVERIFY(!dpms->isSupported());
|
|
|
|
m_serverOutput->setDpmsSupported(true);
|
|
|
|
QVERIFY(supportedChangedSpy.wait());
|
|
|
|
QCOMPARE(supportedChangedSpy.count(), 2);
|
|
|
|
QVERIFY(dpms->isSupported());
|
|
|
|
|
2020-05-19 13:11:27 +00:00
|
|
|
// and switch back to off
|
|
|
|
m_serverOutput->setDpmsMode(OutputInterface::DpmsMode::Off);
|
2016-04-08 09:42:51 +00:00
|
|
|
QVERIFY(clientDpmsModeChangedSpy.wait());
|
|
|
|
QCOMPARE(clientDpmsModeChangedSpy.count(), 2);
|
2020-05-19 13:11:27 +00:00
|
|
|
QCOMPARE(dpms->mode(), Dpms::Mode::Off);
|
2016-04-08 09:42:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestWaylandOutput::testDpmsRequestMode_data()
|
|
|
|
{
|
|
|
|
using namespace KWayland::Client;
|
2020-04-29 14:56:38 +00:00
|
|
|
using namespace KWaylandServer;
|
2016-04-08 09:42:51 +00:00
|
|
|
|
|
|
|
QTest::addColumn<KWayland::Client::Dpms::Mode>("client");
|
2020-04-29 14:56:38 +00:00
|
|
|
QTest::addColumn<KWaylandServer::OutputInterface::DpmsMode>("server");
|
2016-04-08 09:42:51 +00:00
|
|
|
|
|
|
|
QTest::newRow("Standby") << Dpms::Mode::Standby << OutputInterface::DpmsMode::Standby;
|
|
|
|
QTest::newRow("Suspend") << Dpms::Mode::Suspend << OutputInterface::DpmsMode::Suspend;
|
|
|
|
QTest::newRow("Off") << Dpms::Mode::Off << OutputInterface::DpmsMode::Off;
|
|
|
|
QTest::newRow("On") << Dpms::Mode::On << OutputInterface::DpmsMode::On;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestWaylandOutput::testDpmsRequestMode()
|
|
|
|
{
|
|
|
|
// this test verifies that requesting a dpms change from client side emits the signal on server side
|
|
|
|
using namespace KWayland::Client;
|
2020-04-29 14:56:38 +00:00
|
|
|
using namespace KWaylandServer;
|
2016-04-08 09:42:51 +00:00
|
|
|
|
|
|
|
// setup code
|
2021-04-22 15:31:26 +00:00
|
|
|
DpmsManagerInterface iface(m_display);
|
2016-04-08 09:42:51 +00:00
|
|
|
|
|
|
|
// set Dpms on the Output
|
|
|
|
QSignalSpy serverDpmsSupportedChangedSpy(m_serverOutput, &OutputInterface::dpmsSupportedChanged);
|
|
|
|
QVERIFY(serverDpmsSupportedChangedSpy.isValid());
|
|
|
|
QCOMPARE(m_serverOutput->isDpmsSupported(), false);
|
|
|
|
m_serverOutput->setDpmsSupported(true);
|
|
|
|
QCOMPARE(serverDpmsSupportedChangedSpy.count(), 1);
|
|
|
|
QCOMPARE(m_serverOutput->isDpmsSupported(), true);
|
|
|
|
|
|
|
|
KWayland::Client::Registry registry;
|
|
|
|
registry.setEventQueue(m_queue);
|
|
|
|
QSignalSpy announced(®istry, &Registry::interfacesAnnounced);
|
|
|
|
QVERIFY(announced.isValid());
|
|
|
|
QSignalSpy dpmsAnnouncedSpy(®istry, &Registry::dpmsAnnounced);
|
|
|
|
QVERIFY(dpmsAnnouncedSpy.isValid());
|
|
|
|
registry.create(m_connection->display());
|
|
|
|
QVERIFY(registry.isValid());
|
|
|
|
registry.setup();
|
|
|
|
m_connection->flush();
|
|
|
|
QVERIFY(announced.wait());
|
|
|
|
QCOMPARE(dpmsAnnouncedSpy.count(), 1);
|
|
|
|
|
|
|
|
Output *output = registry.createOutput(registry.interface(Registry::Interface::Output).name, registry.interface(Registry::Interface::Output).version, ®istry);
|
|
|
|
|
|
|
|
DpmsManager *dpmsManager = registry.createDpmsManager(dpmsAnnouncedSpy.first().first().value<quint32>(), dpmsAnnouncedSpy.first().last().value<quint32>(), ®istry);
|
|
|
|
QVERIFY(dpmsManager->isValid());
|
|
|
|
|
|
|
|
Dpms *dpms = dpmsManager->getDpms(output, ®istry);
|
|
|
|
// and test request mode
|
|
|
|
QSignalSpy modeRequestedSpy(m_serverOutput, &OutputInterface::dpmsModeRequested);
|
|
|
|
QVERIFY(modeRequestedSpy.isValid());
|
|
|
|
|
|
|
|
QFETCH(Dpms::Mode, client);
|
|
|
|
dpms->requestMode(client);
|
|
|
|
QVERIFY(modeRequestedSpy.wait());
|
|
|
|
QTEST(modeRequestedSpy.last().first().value<OutputInterface::DpmsMode>(), "server");
|
2015-09-01 12:02:38 +00:00
|
|
|
}
|
|
|
|
|
2014-09-23 10:00:17 +00:00
|
|
|
QTEST_GUILESS_MAIN(TestWaylandOutput)
|
2014-08-19 14:08:02 +00:00
|
|
|
#include "test_wayland_output.moc"
|