You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
2.8 KiB
91 lines
2.8 KiB
/******************************************************************** |
|
Copyright 2016 Marco Martin <mart@kde.org> |
|
|
|
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. |
|
|
|
This library is distributed in the hope that it will be useful, |
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
Lesser General Public License for more details. |
|
|
|
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/>. |
|
*********************************************************************/ |
|
|
|
#include <QObject> |
|
|
|
#include <QDir> |
|
#include <QStandardPaths> |
|
#include <QTemporaryDir> |
|
#include <QTest> |
|
|
|
#include "../screenpool.h" |
|
|
|
class ScreenPoolTest : public QObject |
|
{ |
|
Q_OBJECT |
|
|
|
private Q_SLOTS: |
|
void initTestCase(); |
|
void cleanupTestCase(); |
|
|
|
void testScreenInsertion(); |
|
void testPrimarySwap(); |
|
|
|
private: |
|
ScreenPool *m_screenPool; |
|
}; |
|
|
|
void ScreenPoolTest::initTestCase() |
|
{ |
|
QStandardPaths::enableTestMode(true); |
|
|
|
KConfigGroup cg(KSharedConfig::openConfig(), QStringLiteral("ScreenConnectors")); |
|
cg.deleteGroup(); |
|
cg.sync(); |
|
m_screenPool = new ScreenPool(KSharedConfig::openConfig(), this); |
|
} |
|
|
|
void ScreenPoolTest::cleanupTestCase() |
|
{ |
|
KConfigGroup cg(KSharedConfig::openConfig(), QStringLiteral("ScreenConnectors")); |
|
cg.deleteGroup(); |
|
cg.sync(); |
|
} |
|
|
|
void ScreenPoolTest::testScreenInsertion() |
|
{ |
|
m_screenPool->insertScreenMapping(0, QStringLiteral("DVI-0")); |
|
QCOMPARE(m_screenPool->knownIds().count(), 1); |
|
QCOMPARE(m_screenPool->connector(0), QStringLiteral("DVI-0")); |
|
QCOMPARE(m_screenPool->id(QStringLiteral("DVI-0")), 0); |
|
|
|
m_screenPool->insertScreenMapping(1, QStringLiteral("VGA-0")); |
|
QCOMPARE(m_screenPool->knownIds().count(), 2); |
|
QCOMPARE(m_screenPool->connector(1), QStringLiteral("VGA-0")); |
|
QCOMPARE(m_screenPool->id(QStringLiteral("VGA-0")), 1); |
|
} |
|
|
|
void ScreenPoolTest::testPrimarySwap() |
|
{ |
|
QCOMPARE(m_screenPool->primaryConnector(), QStringLiteral("DVI-0")); |
|
m_screenPool->setPrimaryConnector(QStringLiteral("VGA-0")); |
|
|
|
QCOMPARE(m_screenPool->knownIds().count(), 2); |
|
|
|
QCOMPARE(m_screenPool->connector(0), QStringLiteral("VGA-0")); |
|
QCOMPARE(m_screenPool->id(QStringLiteral("VGA-0")), 0); |
|
|
|
QCOMPARE(m_screenPool->connector(1), QStringLiteral("DVI-0")); |
|
QCOMPARE(m_screenPool->id(QStringLiteral("DVI-0")), 1); |
|
} |
|
|
|
QTEST_MAIN(ScreenPoolTest) |
|
|
|
#include "screenpooltest.moc"
|
|
|