2014-08-19 14:08:02 +00:00
|
|
|
/********************************************************************
|
2014-09-17 13:57:56 +00:00
|
|
|
Copyright 2014 Martin Gräßlin <mgraesslin@kde.org>
|
2014-08-19 14:08:02 +00:00
|
|
|
|
2014-09-17 13:57:56 +00:00
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) version 3, or any
|
|
|
|
later version accepted by the membership of KDE e.V. (or its
|
|
|
|
successor approved by the membership of KDE e.V.), which shall
|
|
|
|
act as a proxy defined in Section 6 of version 3 of the license.
|
2014-08-19 14:08:02 +00:00
|
|
|
|
2014-09-17 13:57:56 +00:00
|
|
|
This library is distributed in the hope that it will be useful,
|
2014-08-19 14:08:02 +00:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2014-09-17 13:57:56 +00:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
2014-08-19 14:08:02 +00:00
|
|
|
|
2014-09-17 13:57:56 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2014-08-19 14:08:02 +00:00
|
|
|
*********************************************************************/
|
|
|
|
// Qt
|
|
|
|
#include <QtTest/QtTest>
|
|
|
|
// KWin
|
2014-09-17 12:35:33 +00:00
|
|
|
#include "../../src/client/connection_thread.h"
|
|
|
|
#include "../../src/client/output.h"
|
|
|
|
#include "../../src/client/registry.h"
|
|
|
|
#include "../../src/server/display.h"
|
|
|
|
#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();
|
2014-08-26 14:07:39 +00:00
|
|
|
void testModeChanges();
|
|
|
|
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
|
|
|
|
|
|
|
private:
|
2014-09-17 14:10:38 +00:00
|
|
|
KWayland::Server::Display *m_display;
|
|
|
|
KWayland::Server::OutputInterface *m_serverOutput;
|
2014-09-17 14:17:26 +00:00
|
|
|
KWayland::Client::ConnectionThread *m_connection;
|
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()
|
|
|
|
{
|
2014-09-17 14:10:38 +00:00
|
|
|
using namespace KWayland::Server;
|
2014-08-26 14:07:39 +00:00
|
|
|
delete m_display;
|
|
|
|
m_display = new Display(this);
|
|
|
|
m_display->setSocketName(s_socketName);
|
|
|
|
m_display->start();
|
|
|
|
QVERIFY(m_display->isRunning());
|
|
|
|
|
|
|
|
m_serverOutput = m_display->createOutput(this);
|
2014-09-23 13:56:13 +00:00
|
|
|
m_serverOutput->addMode(QSize(800, 600), OutputInterface::ModeFlags(OutputInterface::ModeFlag::Preferred));
|
2014-08-26 14:07:39 +00:00
|
|
|
m_serverOutput->addMode(QSize(1024, 768));
|
2014-09-23 13:56:13 +00:00
|
|
|
m_serverOutput->addMode(QSize(1280, 1024), OutputInterface::ModeFlags(), 90000);
|
2014-08-26 14:07:39 +00:00
|
|
|
m_serverOutput->setCurrentMode(QSize(1024, 768));
|
|
|
|
m_serverOutput->create();
|
|
|
|
|
|
|
|
// setup connection
|
2014-09-17 14:17:26 +00:00
|
|
|
m_connection = new KWayland::Client::ConnectionThread;
|
2014-08-26 14:07:39 +00:00
|
|
|
QSignalSpy connectedSpy(m_connection, SIGNAL(connected()));
|
|
|
|
m_connection->setSocketName(s_socketName);
|
|
|
|
|
|
|
|
m_thread = new QThread(this);
|
|
|
|
m_connection->moveToThread(m_thread);
|
|
|
|
m_thread->start();
|
|
|
|
|
|
|
|
m_connection->initConnection();
|
|
|
|
QVERIFY(connectedSpy.wait());
|
2014-08-19 14:08:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestWaylandOutput::cleanup()
|
|
|
|
{
|
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_serverOutput;
|
|
|
|
m_serverOutput = nullptr;
|
|
|
|
|
|
|
|
delete m_display;
|
|
|
|
m_display = nullptr;
|
2014-08-19 14:08:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestWaylandOutput::testRegistry()
|
|
|
|
{
|
2014-08-26 14:07:39 +00:00
|
|
|
m_serverOutput->setGlobalPosition(QPoint(100, 50));
|
|
|
|
m_serverOutput->setPhysicalSize(QSize(200, 100));
|
2014-08-19 14:08:02 +00:00
|
|
|
|
2014-09-17 14:17:26 +00:00
|
|
|
KWayland::Client::Registry registry;
|
2014-08-19 14:08:02 +00:00
|
|
|
QSignalSpy announced(®istry, SIGNAL(outputAnnounced(quint32,quint32)));
|
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
|
|
|
|
|
|
|
QSignalSpy outputChanged(&output, SIGNAL(changed()));
|
|
|
|
QVERIFY(outputChanged.isValid());
|
|
|
|
|
|
|
|
output.setup(registry.bindOutput(announced.first().first().value<quint32>(), announced.first().last().value<quint32>()));
|
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
|
|
|
}
|
|
|
|
|
2014-08-26 14:07:39 +00:00
|
|
|
void TestWaylandOutput::testModeChanges()
|
|
|
|
{
|
2014-09-23 13:56:13 +00:00
|
|
|
using namespace KWayland::Client;
|
2014-09-17 14:17:26 +00:00
|
|
|
KWayland::Client::Registry registry;
|
2014-08-26 14:07:39 +00:00
|
|
|
QSignalSpy announced(®istry, SIGNAL(outputAnnounced(quint32,quint32)));
|
|
|
|
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;
|
2014-08-26 14:07:39 +00:00
|
|
|
QSignalSpy outputChanged(&output, SIGNAL(changed()));
|
|
|
|
QVERIFY(outputChanged.isValid());
|
2014-09-23 13:56:13 +00:00
|
|
|
QSignalSpy modeAddedSpy(&output, SIGNAL(modeAdded(KWayland::Client::Output::Mode)));
|
|
|
|
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());
|
2014-09-23 13:56:13 +00:00
|
|
|
QCOMPARE(modeAddedSpy.count(), 3);
|
|
|
|
QCOMPARE(modeAddedSpy.at(0).first().value<Output::Mode>().size, QSize(800, 600));
|
|
|
|
QCOMPARE(modeAddedSpy.at(0).first().value<Output::Mode>().refreshRate, 60000);
|
|
|
|
QCOMPARE(modeAddedSpy.at(0).first().value<Output::Mode>().flags, Output::Mode::Flags(Output::Mode::Flag::Preferred));
|
|
|
|
QCOMPARE(modeAddedSpy.at(0).first().value<Output::Mode>().output, QPointer<Output>(&output));
|
|
|
|
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::None));
|
|
|
|
QCOMPARE(modeAddedSpy.at(1).first().value<Output::Mode>().output, QPointer<Output>(&output));
|
|
|
|
QCOMPARE(modeAddedSpy.at(2).first().value<Output::Mode>().size, QSize(1024, 768));
|
|
|
|
QCOMPARE(modeAddedSpy.at(2).first().value<Output::Mode>().refreshRate, 60000);
|
|
|
|
QCOMPARE(modeAddedSpy.at(2).first().value<Output::Mode>().flags, Output::Mode::Flags(Output::Mode::Flag::Current));
|
|
|
|
QCOMPARE(modeAddedSpy.at(2).first().value<Output::Mode>().output, QPointer<Output>(&output));
|
|
|
|
const QList<Output::Mode> &modes = output.modes();
|
|
|
|
QCOMPARE(modes.size(), 3);
|
|
|
|
QCOMPARE(modes.at(0), modeAddedSpy.at(0).first().value<Output::Mode>());
|
|
|
|
QCOMPARE(modes.at(1), modeAddedSpy.at(1).first().value<Output::Mode>());
|
|
|
|
QCOMPARE(modes.at(2), modeAddedSpy.at(2).first().value<Output::Mode>());
|
2014-08-26 14:07:39 +00:00
|
|
|
|
|
|
|
QCOMPARE(output.pixelSize(), QSize(1024, 768));
|
|
|
|
|
|
|
|
// change the current mode
|
|
|
|
outputChanged.clear();
|
2014-09-23 13:56:13 +00:00
|
|
|
QSignalSpy modeChangedSpy(&output, SIGNAL(modeChanged(KWayland::Client::Output::Mode)));
|
|
|
|
QVERIFY(modeChangedSpy.isValid());
|
2014-08-26 14:07:39 +00:00
|
|
|
m_serverOutput->setCurrentMode(QSize(800, 600));
|
2014-09-23 13:56:13 +00:00
|
|
|
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<Output::Mode>().size, QSize(1024, 768));
|
|
|
|
QCOMPARE(modeChangedSpy.first().first().value<Output::Mode>().refreshRate, 60000);
|
|
|
|
QCOMPARE(modeChangedSpy.first().first().value<Output::Mode>().flags, Output::Mode::Flags());
|
|
|
|
// the one which got the current flag
|
|
|
|
QCOMPARE(modeChangedSpy.last().first().value<Output::Mode>().size, QSize(800, 600));
|
|
|
|
QCOMPARE(modeChangedSpy.last().first().value<Output::Mode>().refreshRate, 60000);
|
|
|
|
QCOMPARE(modeChangedSpy.last().first().value<Output::Mode>().flags, Output::Mode::Flags(Output::Mode::Flag::Current | Output::Mode::Flag::Preferred));
|
|
|
|
QVERIFY(!outputChanged.isEmpty());
|
2014-08-26 14:07:39 +00:00
|
|
|
QCOMPARE(output.pixelSize(), QSize(800, 600));
|
2014-09-23 13:56:13 +00:00
|
|
|
const QList<Output::Mode> &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);
|
2014-08-26 14:07:39 +00:00
|
|
|
|
|
|
|
// change once more
|
|
|
|
outputChanged.clear();
|
2014-09-23 13:56:13 +00:00
|
|
|
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<Output::Mode>().size, QSize(800, 600));
|
|
|
|
QCOMPARE(modeChangedSpy.first().first().value<Output::Mode>().refreshRate, 60000);
|
|
|
|
QCOMPARE(modeChangedSpy.first().first().value<Output::Mode>().flags, Output::Mode::Flags(Output::Mode::Flag::Preferred));
|
|
|
|
// the one which got the current flag
|
|
|
|
QCOMPARE(modeChangedSpy.last().first().value<Output::Mode>().size, QSize(1280, 1024));
|
|
|
|
QCOMPARE(modeChangedSpy.last().first().value<Output::Mode>().refreshRate, 90000);
|
|
|
|
QCOMPARE(modeChangedSpy.last().first().value<Output::Mode>().flags, Output::Mode::Flags(Output::Mode::Flag::Current));
|
|
|
|
QVERIFY(!outputChanged.isEmpty());
|
2014-08-26 14:07:39 +00:00
|
|
|
QCOMPARE(output.pixelSize(), QSize(1280, 1024));
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestWaylandOutput::testScaleChange()
|
|
|
|
{
|
2014-09-17 14:17:26 +00:00
|
|
|
KWayland::Client::Registry registry;
|
2014-08-26 14:07:39 +00:00
|
|
|
QSignalSpy announced(®istry, SIGNAL(outputAnnounced(quint32,quint32)));
|
|
|
|
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;
|
2014-08-26 14:07:39 +00:00
|
|
|
QSignalSpy outputChanged(&output, SIGNAL(changed()));
|
|
|
|
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();
|
|
|
|
m_serverOutput->setScale(2);
|
|
|
|
QVERIFY(outputChanged.wait());
|
|
|
|
QCOMPARE(output.scale(), 2);
|
|
|
|
|
|
|
|
// change once more
|
|
|
|
outputChanged.clear();
|
|
|
|
m_serverOutput->setScale(4);
|
|
|
|
QVERIFY(outputChanged.wait());
|
|
|
|
QCOMPARE(output.scale(), 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestWaylandOutput::testSubPixel_data()
|
|
|
|
{
|
2014-09-17 14:17:26 +00:00
|
|
|
using namespace KWayland::Client;
|
2014-09-17 14:10:38 +00:00
|
|
|
using namespace KWayland::Server;
|
2014-09-17 14:17:26 +00:00
|
|
|
QTest::addColumn<KWayland::Client::Output::SubPixel>("expected");
|
2014-09-17 14:10:38 +00:00
|
|
|
QTest::addColumn<KWayland::Server::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;
|
2014-09-17 14:10:38 +00:00
|
|
|
using namespace KWayland::Server;
|
2014-08-26 14:07:39 +00:00
|
|
|
QFETCH(OutputInterface::SubPixel, actual);
|
|
|
|
m_serverOutput->setSubPixel(actual);
|
|
|
|
|
2014-09-17 14:17:26 +00:00
|
|
|
KWayland::Client::Registry registry;
|
2014-08-26 14:07:39 +00:00
|
|
|
QSignalSpy announced(®istry, SIGNAL(outputAnnounced(quint32,quint32)));
|
|
|
|
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;
|
2014-08-26 14:07:39 +00:00
|
|
|
QSignalSpy outputChanged(&output, SIGNAL(changed()));
|
|
|
|
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);
|
|
|
|
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;
|
2014-09-17 14:10:38 +00:00
|
|
|
using namespace KWayland::Server;
|
2014-09-17 14:17:26 +00:00
|
|
|
QTest::addColumn<KWayland::Client::Output::Transform>("expected");
|
2014-09-17 14:10:38 +00:00
|
|
|
QTest::addColumn<KWayland::Server::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;
|
2014-09-17 14:10:38 +00:00
|
|
|
using namespace KWayland::Server;
|
2014-08-26 14:07:39 +00:00
|
|
|
QFETCH(OutputInterface::Transform, actual);
|
|
|
|
m_serverOutput->setTransform(actual);
|
|
|
|
|
2014-09-17 14:17:26 +00:00
|
|
|
KWayland::Client::Registry registry;
|
2014-08-26 14:07:39 +00:00
|
|
|
QSignalSpy announced(®istry, SIGNAL(outputAnnounced(quint32,quint32)));
|
|
|
|
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);
|
|
|
|
QSignalSpy outputChanged(output, SIGNAL(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);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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"
|