Commit 0ae03aa6 authored by Alexander Lohnau's avatar Alexander Lohnau 💬

Run clang-format

If you want git blame to ignore formatting revisions run:
git config blame.ignoreRevsFile .git-blame-ignore-revs
parent 483dd348
......@@ -17,9 +17,9 @@
*************************************************************************************/
#include <QCoreApplication>
#include <QtTest>
#include <QObject>
#include <QSignalSpy>
#include <QtTest>
#include "../src/backendmanager_p.h"
......@@ -77,6 +77,7 @@ void TestBackendLoader::testEnv_data()
QTest::addColumn<QString>("var");
QTest::addColumn<QString>("backend");
// clang-format off
QTest::newRow("all lower") << "kwayland" << "KSC_KWayland";
QTest::newRow("camel case") << "KWayland" << "KSC_KWayland";
QTest::newRow("all upper") << "KWAYLAND" << "KSC_KWayland";
......@@ -85,6 +86,7 @@ void TestBackendLoader::testEnv_data()
QTest::newRow("xrandr 1.1") << "xrandr11" << "KSC_XRandR11";
QTest::newRow("qscreen") << "qscreen" << "KSC_QScreen";
QTest::newRow("mixed") << "fake" << "KSC_Fake";
// clang-format on
}
void TestBackendLoader::testEnv()
......
......@@ -18,17 +18,16 @@
*/
#include <QObject>
#include <QtTest>
#include <QSignalSpy>
#include <QtTest>
#include "../src/backendmanager_p.h"
#include "../src/config.h"
#include "../src/output.h"
#include "../src/configmonitor.h"
#include "../src/configoperation.h"
#include "../src/getconfigoperation.h"
#include "../src/output.h"
#include "../src/setconfigoperation.h"
#include "../src/backendmanager_p.h"
#include <QSignalSpy>
#include "fakebackendinterface.h"
......@@ -72,7 +71,7 @@ private Q_SLOTS:
qputenv("KSCREEN_BACKEND_INPROCESS", "1");
KScreen::BackendManager::instance()->shutdownBackend();
KScreen::BackendManager::instance()->setMethod(KScreen::BackendManager::InProcess);
//json file for the fake backend
// json file for the fake backend
qputenv("KSCREEN_BACKEND_ARGS", "TEST_DATA=" TEST_DATA "singleoutput.json");
// Prepare monitor
......@@ -103,7 +102,6 @@ private Q_SLOTS:
QTRY_VERIFY(!spy.isEmpty());
QCOMPARE(spy.size(), 2);
}
};
QTEST_MAIN(TestConfigMonitor)
......
......@@ -20,11 +20,11 @@
#include <QObject>
#include <QtTest>
#include "../src/types.h"
#include "../src/configserializer_p.h"
#include "../src/screen.h"
#include "../src/mode.h"
#include "../src/output.h"
#include "../src/screen.h"
#include "../src/types.h"
class TestConfigSerializer : public QObject
{
......@@ -35,7 +35,6 @@ public:
{
}
private Q_SLOTS:
void testSerializePoint()
{
......@@ -62,10 +61,7 @@ private Q_SLOTS:
void testSerializeList()
{
QStringList stringList;
stringList << QStringLiteral("Item 1")
<< QStringLiteral("Item 2")
<< QStringLiteral("Item 3")
<< QStringLiteral("Item 4");
stringList << QStringLiteral("Item 1") << QStringLiteral("Item 2") << QStringLiteral("Item 3") << QStringLiteral("Item 4");
QJsonArray arr = KScreen::ConfigSerializer::serializeList<QString>(stringList);
QCOMPARE(arr.size(), stringList.size());
......@@ -74,8 +70,6 @@ private Q_SLOTS:
QCOMPARE(arr.at(i).toString(), stringList.at(i));
}
QList<int> intList;
intList << 4 << 3 << 2 << 1;
......@@ -125,7 +119,7 @@ private Q_SLOTS:
QCOMPARE(obj[QLatin1String("id")].toString(), mode->id());
QCOMPARE(obj[QLatin1String("name")].toString(), mode->name());
QCOMPARE((float) obj[QLatin1String("refreshRate")].toDouble(), mode->refreshRate());
QCOMPARE((float)obj[QLatin1String("refreshRate")].toDouble(), mode->refreshRate());
const QJsonObject size = obj[QLatin1String("size")].toObject();
QCOMPARE(size[QLatin1String("width")].toInt(), mode->size().width());
QCOMPARE(size[QLatin1String("height")].toInt(), mode->size().height());
......
......@@ -17,8 +17,8 @@
*************************************************************************************/
#include <QCoreApplication>
#include <QtTest>
#include <QObject>
#include <QtTest>
#include "../src/edid.h"
......@@ -69,7 +69,7 @@ void TestEdid::testEdidParser_data()
QTest::addColumn<QQuaternion>("green");
QTest::addColumn<QQuaternion>("blue");
QTest::addColumn<QQuaternion>("white");
// clang-format off
QTest::addRow("cor")
<< QByteArray::fromBase64("AP///////wAN8iw0AAAAABwVAQOAHRB4CoPVlFdSjCccUFQAAAABAQEBAQEBAQEBAQEBAQEBEhtWWlAAGTAwIDYAJaQQAAAYEhtWWlAAGTAwIDYAJaQQAAAYAAAA/gBBVU8KICAgICAgICAgAAAA/gBCMTMzWFcwMyBWNCAKAIc=")
<< QStringLiteral("xrandr-unknown")
......@@ -128,6 +128,7 @@ void TestEdid::testEdidParser_data()
<< QQuaternion(1, QVector3D(0.299805, 0.599609, 0))
<< QQuaternion(1, QVector3D(0.149414, 0.0595703, 0))
<< QQuaternion(1, QVector3D(0.3125, 0.328125, 0));
// clang-format on
}
void TestEdid::testEdidParser()
......@@ -156,7 +157,7 @@ void TestEdid::testEdidParser()
QCOMPARE(e->name(), name);
QCOMPARE(e->pnpId(), pnpId);
// FIXME: needs to return at least the short ID
// QVERIFY2(vendor.contains(e->vendor()), qPrintable(QString::fromLatin1("%1 not in list").arg(e->vendor())));
// QVERIFY2(vendor.contains(e->vendor()), qPrintable(QString::fromLatin1("%1 not in list").arg(e->vendor())));
QCOMPARE(e->serial(), serial);
QCOMPARE(e->eisaId(), eisaId);
QCOMPARE(e->hash(), hash);
......
......@@ -17,19 +17,19 @@
*************************************************************************************/
#include <QCoreApplication>
#include <QtTest>
#include <QDBusConnectionInterface>
#include <QObject>
#include <QSignalSpy>
#include <QDBusConnectionInterface>
#include <QtTest>
#include "../src/backendmanager_p.h"
#include "../src/getconfigoperation.h"
#include "../src/setconfigoperation.h"
#include "../src/config.h"
#include "../src/configmonitor.h"
#include "../src/output.h"
#include "../src/mode.h"
#include "../src/edid.h"
#include "../src/getconfigoperation.h"
#include "../src/mode.h"
#include "../src/output.h"
#include "../src/setconfigoperation.h"
Q_LOGGING_CATEGORY(KSCREEN, "kscreen")
......@@ -58,10 +58,8 @@ private Q_SLOTS:
void testConfigMonitor();
private:
ConfigPtr m_config;
bool m_backendServiceInstalled = false;
};
TestInProcess::TestInProcess(QObject *parent)
......@@ -196,7 +194,7 @@ void TestInProcess::testBackendCaching()
QVERIFY(cc->outputs().count());
}
{
//KScreen::BackendManager::instance()->shutdownBackend();
// KScreen::BackendManager::instance()->shutdownBackend();
QCOMPARE(BackendManager::instance()->method(), BackendManager::InProcess);
t.start();
auto cp = new GetConfigOperation();
......@@ -220,7 +218,7 @@ void TestInProcess::testBackendCaching()
KScreen::BackendManager::instance()->shutdownBackend();
if (m_backendServiceInstalled) {
//qputenv("KSCREEN_BACKEND", "QScreen");
// qputenv("KSCREEN_BACKEND", "QScreen");
qputenv("KSCREEN_BACKEND_INPROCESS", "0");
BackendManager::instance()->setMethod(BackendManager::OutOfProcess);
QCOMPARE(BackendManager::instance()->method(), BackendManager::OutOfProcess);
......@@ -262,7 +260,7 @@ void TestInProcess::testCreateJob()
{
BackendManager::instance()->setMethod(BackendManager::InProcess);
auto op = new GetConfigOperation();
auto _op = qobject_cast<GetConfigOperation*>(op);
auto _op = qobject_cast<GetConfigOperation *>(op);
QVERIFY(_op != nullptr);
QCOMPARE(BackendManager::instance()->method(), BackendManager::InProcess);
QVERIFY(op->exec());
......@@ -273,7 +271,7 @@ void TestInProcess::testCreateJob()
if (m_backendServiceInstalled) {
BackendManager::instance()->setMethod(BackendManager::OutOfProcess);
auto op = new GetConfigOperation();
auto _op = qobject_cast<GetConfigOperation*>(op);
auto _op = qobject_cast<GetConfigOperation *>(op);
QVERIFY(_op != nullptr);
QCOMPARE(BackendManager::instance()->method(), BackendManager::OutOfProcess);
QVERIFY(op->exec());
......@@ -293,12 +291,12 @@ void TestInProcess::testConfigApply()
auto op = new GetConfigOperation();
op->exec();
auto config = op->config();
// qDebug() << "op:" << config->outputs().count();
// qDebug() << "op:" << config->outputs().count();
auto output = config->outputs().first();
// qDebug() << "res:" << output->geometry();
// qDebug() << "modes:" << output->modes();
// qDebug() << "res:" << output->geometry();
// qDebug() << "modes:" << output->modes();
auto m0 = output->modes().first();
//qDebug() << "m0:" << m0->id() << m0;
// qDebug() << "m0:" << m0->id() << m0;
output->setCurrentModeId(m0->id());
QVERIFY(Config::canBeApplied(config));
......@@ -324,7 +322,7 @@ void TestInProcess::testConfigMonitor()
// qDebug() << "res:" << output->geometry();
// qDebug() << "modes:" << output->modes();
auto m0 = output->modes().first();
//qDebug() << "m0:" << m0->id() << m0;
// qDebug() << "m0:" << m0->id() << m0;
output->setCurrentModeId(m0->id());
QVERIFY(Config::canBeApplied(config));
......@@ -338,7 +336,6 @@ void TestInProcess::testConfigMonitor()
QVERIFY(monitorSpy.wait(500));
}
QTEST_GUILESS_MAIN(TestInProcess)
#include "testinprocess.moc"
......@@ -18,17 +18,17 @@
#include <QCoreApplication>
#include <QCryptographicHash>
#include <QtTest>
#include <QObject>
#include <QtTest>
#include "../src/backendmanager_p.h"
#include "../src/getconfigoperation.h"
#include "../src/setconfigoperation.h"
#include "../src/config.h"
#include "../src/configmonitor.h"
#include "../src/output.h"
#include "../src/mode.h"
#include "../src/edid.h"
#include "../src/getconfigoperation.h"
#include "../src/mode.h"
#include "../src/output.h"
#include "../src/setconfigoperation.h"
// KWayland
#include <KWayland/Server/display.h>
......@@ -63,7 +63,6 @@ private Q_SLOTS:
void removeOutput();
void testEdid();
private:
ConfigPtr m_config;
WaylandTestServer *m_server;
......@@ -133,7 +132,7 @@ void testWaylandBackend::verifyOutputs()
primaryFound = true;
}
}
//qCDebug(KSCREEN_WAYLAND) << "Primary found? " << primaryFound << m_config->outputs();
// qCDebug(KSCREEN_WAYLAND) << "Primary found? " << primaryFound << m_config->outputs();
QVERIFY(primaryFound);
QVERIFY(m_config->outputs().count());
QCOMPARE(m_server->outputCount(), m_config->outputs().count());
......@@ -147,7 +146,7 @@ void testWaylandBackend::verifyOutputs()
QVERIFY(!output->name().isEmpty());
QVERIFY(output->id() > -1);
QVERIFY(output->isConnected());
QVERIFY(output->geometry() != QRectF(1,1,1,1));
QVERIFY(output->geometry() != QRectF(1, 1, 1, 1));
QVERIFY(output->geometry() != QRectF());
QVERIFY(output->sizeMm() != QSize());
QVERIFY(output->edid() != nullptr);
......@@ -242,7 +241,7 @@ void testWaylandBackend::addOutput()
m_serverOutputDevice->create();
QVERIFY(configSpy.wait());
//QTRY_VERIFY(configSpy.count());
// QTRY_VERIFY(configSpy.count());
GetConfigOperation *op2 = new GetConfigOperation();
op2->exec();
......@@ -273,7 +272,10 @@ void testWaylandBackend::testEdid()
{
m_server->showOutputs();
QByteArray data = QByteArray::fromBase64("AP///////wAQrBbwTExLQQ4WAQOANCB46h7Frk80sSYOUFSlSwCBgKlA0QBxTwEBAQEBAQEBKDyAoHCwI0AwIDYABkQhAAAaAAAA/wBGNTI1TTI0NUFLTEwKAAAA/ABERUxMIFUyNDEwCiAgAAAA/QA4TB5REQAKICAgICAgAToCAynxUJAFBAMCBxYBHxITFCAVEQYjCQcHZwMMABAAOC2DAQAA4wUDAQI6gBhxOC1AWCxFAAZEIQAAHgEdgBhxHBYgWCwlAAZEIQAAngEdAHJR0B4gbihVAAZEIQAAHowK0Iog4C0QED6WAAZEIQAAGAAAAAAAAAAAAAAAAAAAPg==");
QByteArray data = QByteArray::fromBase64(
"AP///////wAQrBbwTExLQQ4WAQOANCB46h7Frk80sSYOUFSlSwCBgKlA0QBxTwEBAQEBAQEBKDyAoHCwI0AwIDYABkQhAAAaAAAA/wBGNTI1TTI0NUFLTEwKAAAA/ABERUxMIFUyNDEwCiAgAAAA/"
"QA4TB5REQAKICAgICAgAToCAynxUJAFBAMCBxYBHxITFCAVEQYjCQcHZwMMABAAOC2DAQAA4wUDAQI6gBhxOC1AWCxFAAZEIQAAHgEdgBhxHBYgWCwlAAZEIQAAngEdAHJR0B4gbihVAAZEIQAAHow"
"K0Iog4C0QED6WAAZEIQAAGAAAAAAAAAAAAAAAAAAAPg==");
QScopedPointer<Edid> edid(new Edid(data));
QVERIFY(edid->isValid());
......@@ -311,7 +313,6 @@ void testWaylandBackend::verifyFeatures()
QVERIFY(!config->supportedFeatures().testFlag(Config::Feature::PrimaryDisplay));
}
QTEST_GUILESS_MAIN(testWaylandBackend)
#include "testkwaylandbackend.moc"
......@@ -17,18 +17,18 @@
*************************************************************************************/
#include <QCoreApplication>
#include <QtTest>
#include <QObject>
#include <QSignalSpy>
#include <QtTest>
#include "backendmanager_p.h"
#include "getconfigoperation.h"
#include "setconfigoperation.h"
#include "config.h"
#include "configmonitor.h"
#include "output.h"
#include "mode.h"
#include "edid.h"
#include "getconfigoperation.h"
#include "mode.h"
#include "output.h"
#include "setconfigoperation.h"
#include "waylandtestserver.h"
......@@ -56,9 +56,7 @@ private Q_SLOTS:
void testApplyOnPending();
private:
WaylandTestServer *m_server;
};
TestKWaylandConfig::TestKWaylandConfig(QObject *parent)
......@@ -100,7 +98,6 @@ void TestKWaylandConfig::changeConfig()
monitor->addConfig(config);
QSignalSpy configSpy(monitor, &KScreen::ConfigMonitor::configurationChanged);
// The first output is currently disabled, let's try to enable it
auto output = config->outputs().first();
QVERIFY(output->isEnabled() == false);
......@@ -196,7 +193,6 @@ void TestKWaylandConfig::testRotationChange()
auto newoutput = newconfig->outputs().first();
QCOMPARE(newoutput->rotation(), rotation);
}
void TestKWaylandConfig::testScaleChange()
......@@ -320,7 +316,6 @@ void TestKWaylandConfig::testApplyOnPending()
QCOMPARE(output2->scale(), 3.0);
}
QTEST_GUILESS_MAIN(TestKWaylandConfig)
#include "testkwaylandconfig.moc"
......@@ -17,9 +17,9 @@
*************************************************************************************/
#include <QCoreApplication>
#include <QtTest>
#include <QObject>
#include <QSignalSpy>
#include <QtTest>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/dpms.h>
......@@ -27,7 +27,6 @@
#include "waylandtestserver.h"
static const QString s_socketName = QStringLiteral("libkscreen-test-wayland-backend-0");
// static const QString s_socketName = QStringLiteral("wayland-0");
......@@ -45,7 +44,6 @@ public:
Q_SIGNALS:
void dpmsAnnounced();
private Q_SLOTS:
void initTestCase();
......@@ -91,16 +89,15 @@ void TestDpmsClient::initTestCase()
m_registry = new KWayland::Client::Registry;
m_registry->create(m_connection);
QObject::connect(m_registry, &Registry::interfacesAnnounced, this,
[this] {
const bool hasDpms = m_registry->hasInterface(Registry::Interface::Dpms);
if (hasDpms) {
qDebug() << QStringLiteral("Compositor provides a DpmsManager");
} else {
qDebug() << QStringLiteral("Compositor does not provid a DpmsManager");
}
emit this->dpmsAnnounced();
});
QObject::connect(m_registry, &Registry::interfacesAnnounced, this, [this] {
const bool hasDpms = m_registry->hasInterface(Registry::Interface::Dpms);
if (hasDpms) {
qDebug() << QStringLiteral("Compositor provides a DpmsManager");
} else {
qDebug() << QStringLiteral("Compositor does not provid a DpmsManager");
}
emit this->dpmsAnnounced();
});
m_registry->setup();
QVERIFY(dpmsSpy.wait(100));
......@@ -120,7 +117,6 @@ void TestDpmsClient::testDpmsConnect()
QVERIFY(m_registry->isValid());
}
QTEST_GUILESS_MAIN(TestDpmsClient)
#include "testkwaylanddpms.moc"
......@@ -16,9 +16,9 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
*************************************************************************************/
#include <QtTest>
#include <QObject>
#include <QLoggingCategory>
#include <QObject>
#include <QtTest>
#include "../src/log.h"
......@@ -54,7 +54,6 @@ void TestLog::init()
void TestLog::initTestCase()
{
qputenv(KSCREEN_LOGGING, QByteArray("true"));
}
......
......@@ -16,20 +16,19 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
*************************************************************************************/
#include <QtTest>
#include <QObject>
#include <QtTest>
#include "../src/backendmanager_p.h"
#include "../src/config.h"
#include "../src/configmonitor.h"
#include "../src/output.h"
#include "../src/mode.h"
#include "../src/getconfigoperation.h"
#include "../src/mode.h"
#include "../src/output.h"
#include "../src/setconfigoperation.h"
#include "../src/backendmanager_p.h"
using namespace KScreen;
class TestModeListChange : public QObject
{
Q_OBJECT
......@@ -70,7 +69,6 @@ ConfigPtr TestModeListChange::getConfig()
KScreen::ModeList TestModeListChange::createModeList()
{
KScreen::ModeList newmodes;
{
QString _id = QString::number(11);
......@@ -102,7 +100,6 @@ KScreen::ModeList TestModeListChange::createModeList()
return newmodes;
}
void TestModeListChange::initTestCase()
{
qputenv("KSCREEN_LOGGING", "false");
......@@ -116,7 +113,7 @@ void TestModeListChange::cleanupTestCase()
void TestModeListChange::modeListChange()
{
//json file for the fake backend
// json file for the fake backend
qputenv("KSCREEN_BACKEND_ARGS", "TEST_DATA=" TEST_DATA "singleoutput.json");
const ConfigPtr config = getConfig();
......@@ -173,7 +170,6 @@ void TestModeListChange::modeListChange()
QCOMPARE(outputChangedSpy.count(), modesChangedSpy.count());
}
QTEST_MAIN(TestModeListChange)
#include "testmodelistchange.moc"
......@@ -17,16 +17,16 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
*************************************************************************************/
#include <QtTest>
#include <QObject>
#include <QElapsedTimer>
#include <QObject>
#include <QtTest>
#include "../src/backendmanager_p.h"
#include "../src/config.h"
#include "../src/output.h"
#include "../src/mode.h"
#include "../src/edid.h"
#include "../src/getconfigoperation.h"
#include "../src/backendmanager_p.h"
#include "../src/mode.h"
#include "../src/output.h"
Q_LOGGING_CATEGORY(KSCREEN_QSCREEN, "kscreen.qscreen")
......@@ -93,7 +93,6 @@ void testQScreenBackend::verifyScreen()
QVERIFY(m_config->screen()->maxActiveOutputsCount() > 0);
}
void testQScreenBackend::verifyOutputs()
{
bool primaryFound = false;
......@@ -111,9 +110,8 @@ void testQScreenBackend::verifyOutputs()
const KScreen::OutputPtr primary = m_config->primaryOutput();
QVERIFY(primary->isEnabled());
QVERIFY(primary->isConnected());
//qDebug() << "Primary geometry? " << primary->geometry();
//qDebug() << " prim modes: " << primary->modes();
// qDebug() << "Primary geometry? " << primary->geometry();
// qDebug() << " prim modes: " << primary->modes();
QList<int> ids;
foreach (const KScreen::OutputPtr &output, m_config->outputs()) {
......@@ -127,7 +125,7 @@ void testQScreenBackend::verifyOutputs()
QVERIFY(output->id() > -1);
QVERIFY(output->isConnected());
QVERIFY(output->isEnabled());
QVERIFY(output->geometry() != QRectF(1,1,1,1));
QVERIFY(output->geometry() != QRectF(1, 1, 1, 1));
QVERIFY(output->geometry() != QRectF());
// Pass, but leave a note, when the x server doesn't report physical size
......@@ -166,7 +164,7 @@ void testQScreenBackend::commonUsagePattern()
const KScreen::OutputList outputs = op->config()->outputs();
QVariantList outputList;
Q_FOREACH(const KScreen::OutputPtr &output, outputs) {
Q_FOREACH (const KScreen::OutputPtr &output, outputs) {
if (!output->isConnected()) {
continue;
}
......@@ -185,7 +183,7 @@ void testQScreenBackend::commonUsagePattern()
if (output->isEnabled()) {
const KScreen::ModePtr mode = output->currentMode();
if (!mode) {
//qWarning() << "CurrentMode is null" << output->name();
// qWarning() << "CurrentMode is null" << output->name();
return;
}
......@@ -220,7 +218,6 @@ void testQScreenBackend::verifyFeatures()
QVERIFY(!config->supportedFeatures().testFlag(Config::Feature::PrimaryDisplay));
}
QTEST_MAIN(testQScreenBackend)
#include "testqscreenbackend.moc"
......@@ -16,16 +16,16 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
*************************************************************************************/
#include <QtTest>
#include <QObject>
#include <QtTest>
#include "../src/screen.h"
#include "../src/backendmanager_p.h"
#include "../src/config.h"
#include "../src/output.h"
#include "../src/mode.h"
#include "../src/getconfigoperation.h"
#i