From 06d195980bfdc7dbd8c728ae4ffade474841d93b Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 28 Feb 2023 22:28:36 +0200 Subject: [PATCH] autotests: Drop night color test It doesn't test anything useful. It's hard to make it test useful things too due to needing to change the system time. Linking with it also breaks the encapsulation and it won't work when using MODULE library. --- autotests/integration/CMakeLists.txt | 1 - autotests/integration/nightcolor_test.cpp | 105 ---------------------- 2 files changed, 106 deletions(-) delete mode 100644 autotests/integration/nightcolor_test.cpp diff --git a/autotests/integration/CMakeLists.txt b/autotests/integration/CMakeLists.txt index 9342154c62..735a5a296f 100644 --- a/autotests/integration/CMakeLists.txt +++ b/autotests/integration/CMakeLists.txt @@ -113,7 +113,6 @@ integrationTest(WAYLAND_ONLY NAME testFractionalScaling SRCS fractional_scaling_ qt_add_dbus_interfaces(DBUS_SRCS ${CMAKE_BINARY_DIR}/src/org.kde.kwin.VirtualKeyboard.xml) integrationTest(WAYLAND_ONLY NAME testVirtualKeyboardDBus SRCS test_virtualkeyboard_dbus.cpp ${DBUS_SRCS}) -integrationTest(WAYLAND_ONLY NAME testNightColor SRCS nightcolor_test.cpp LIBS KWinNightColorPlugin) if (XCB_ICCCM_FOUND) integrationTest(NAME testMoveResize SRCS move_resize_window_test.cpp LIBS XCB::ICCCM) diff --git a/autotests/integration/nightcolor_test.cpp b/autotests/integration/nightcolor_test.cpp deleted file mode 100644 index 52dec18c0e..0000000000 --- a/autotests/integration/nightcolor_test.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - KWin - the KDE window manager - This file is part of the KDE project. - - SPDX-FileCopyrightText: 2017 Roman Gilg - - SPDX-License-Identifier: GPL-2.0-or-later -*/ -#include "kwin_wayland_test.h" - -#include "core/outputbackend.h" -#include "plugins/nightcolor/constants.h" -#include "plugins/nightcolor/nightcolormanager.h" -#include "wayland_server.h" - -#include - -using namespace KWin; - -static const QString s_socketName = QStringLiteral("wayland_test_kwin_nightcolor-0"); - -class NightColorTest : public QObject -{ - Q_OBJECT -private Q_SLOTS: - void initTestCase(); - void init(); - void cleanup(); - - void testConfigRead_data(); - void testConfigRead(); -}; - -void NightColorTest::initTestCase() -{ - QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); - QVERIFY(waylandServer()->init(s_socketName)); - QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector, QVector() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024))); - - kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig)); - - kwinApp()->start(); - QVERIFY(applicationStartedSpy.wait()); - - NightColorManager *manager = NightColorManager::self(); - QVERIFY(manager); -} - -void NightColorTest::init() -{ - QVERIFY(Test::setupWaylandConnection()); -} - -void NightColorTest::cleanup() -{ - Test::destroyWaylandConnection(); -} - -void NightColorTest::testConfigRead_data() -{ - QTest::addColumn("active"); - QTest::addColumn("mode"); - - QTest::newRow("activeMode0") << true << 0; - QTest::newRow("activeMode1") << true << 1; - QTest::newRow("activeMode2") << true << 3; - QTest::newRow("notActiveMode2") << false << 2; - QTest::newRow("wrongData1") << false << 4; -} - -void NightColorTest::testConfigRead() -{ - QFETCH(bool, active); - QFETCH(int, mode); - - const bool activeDefault = true; - const int modeDefault = 0; - - KConfigGroup cfgGroup = kwinApp()->config()->group("NightColor"); - - cfgGroup.writeEntry("Active", activeDefault); - cfgGroup.writeEntry("Mode", modeDefault); - kwinApp()->config()->sync(); - NightColorManager *manager = NightColorManager::self(); - manager->reconfigure(); - - QCOMPARE(manager->isEnabled(), activeDefault); - QCOMPARE(manager->mode(), modeDefault); - - cfgGroup.writeEntry("Active", active); - cfgGroup.writeEntry("Mode", mode); - kwinApp()->config()->sync(); - - manager->reconfigure(); - - QCOMPARE(manager->isEnabled(), active); - if (mode > 3 || mode < 0) { - QCOMPARE(manager->mode(), 0); - } else { - QCOMPARE(manager->mode(), mode); - } -} - -WAYLANDTEST_MAIN(NightColorTest) -#include "nightcolor_test.moc"