File indexing completed on 2024-03-24 17:07:37

0001 /*
0002  *  SPDX-FileCopyrightText: 2012 Alejandro Fiestas Olivares <afiestas@kde.org>
0003  *
0004  *  SPDX-License-Identifier: LGPL-2.1-or-later
0005  */
0006 
0007 #define QT_GUI_LIB
0008 
0009 #include <QObject>
0010 #include <QtTest>
0011 
0012 #include "../src/config.h"
0013 #include "../src/getconfigoperation.h"
0014 #include "../src/output.h"
0015 
0016 using namespace KScreen;
0017 
0018 class testXRandR : public QObject
0019 {
0020     Q_OBJECT
0021 
0022 private Q_SLOTS:
0023     void initTestCase();
0024     void singleOutput();
0025 
0026 private:
0027     QProcess m_process;
0028 };
0029 
0030 void testXRandR::initTestCase()
0031 {
0032 }
0033 
0034 void testXRandR::singleOutput()
0035 {
0036     qputenv("KSCREEN_BACKEND", "XRandR");
0037 
0038     GetConfigOperation *op = new GetConfigOperation();
0039     QVERIFY(op->exec());
0040 
0041     const ConfigPtr config = op->config();
0042     if (!config) {
0043         QSKIP("XRandR X extension is not available", SkipAll);
0044     }
0045 
0046     QCOMPARE(config->outputs().count(), 1);
0047 
0048     const OutputPtr output = config->outputs().take(327);
0049 
0050     QCOMPARE(output->name(), QString("default"));
0051     QCOMPARE(output->type(), Output::Unknown);
0052     QCOMPARE(output->modes().count(), 15);
0053     QCOMPARE(output->pos(), QPoint(0, 0));
0054     QCOMPARE(output->currentModeId(), QLatin1String("338"));
0055     QCOMPARE(output->rotation(), Output::None);
0056     QCOMPARE(output->isConnected(), true);
0057     QCOMPARE(output->isEnabled(), true);
0058     QCOMPARE(output->isPrimary(), false);
0059     QVERIFY2(output->clones().isEmpty(), "In singleOutput is impossible to have clones");
0060 }
0061 
0062 QTEST_MAIN(testXRandR)
0063 
0064 #include "testxrandr.moc"