diff --git a/autotests/libinput/CMakeLists.txt b/autotests/libinput/CMakeLists.txt index 51ee8cb270..d281ee6290 100644 --- a/autotests/libinput/CMakeLists.txt +++ b/autotests/libinput/CMakeLists.txt @@ -52,30 +52,6 @@ target_link_libraries(testLibinputSwitchEvent Qt::Test Qt::DBus Qt::Widgets KF5: add_test(NAME kwin-testLibinputSwitchEvent COMMAND testLibinputSwitchEvent) ecm_mark_as_test(testLibinputSwitchEvent) -######################################################## -# Test Context -######################################################## -set(testLibinputContext_SRCS - ../../src/libinput/context.cpp - ../../src/libinput/libinput_logging.cpp - ../../src/logind.cpp - context_test.cpp - mock_udev.cpp -) -add_executable(testLibinputContext ${testLibinputContext_SRCS}) -target_link_libraries(testLibinputContext - LibInputTestObjects - - Qt::DBus - Qt::Test - Qt::Widgets - - KF5::ConfigCore - KF5::WindowSystem -) -add_test(NAME kwin-testLibinputContext COMMAND testLibinputContext) -ecm_mark_as_test(testLibinputContext) - ######################################################## # Test Input Events ######################################################## diff --git a/autotests/libinput/context_test.cpp b/autotests/libinput/context_test.cpp deleted file mode 100644 index e7551430b6..0000000000 --- a/autotests/libinput/context_test.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - KWin - the KDE window manager - This file is part of the KDE project. - - SPDX-FileCopyrightText: 2016 Martin Gräßlin - - SPDX-License-Identifier: GPL-2.0-or-later -*/ -#include "mock_libinput.h" -#include "mock_udev.h" - -#include "libinput/context.h" -#include "udev.h" - -#include -Q_LOGGING_CATEGORY(KWIN_CORE, "kwin_core", QtWarningMsg) - -using namespace KWin; -using namespace KWin::LibInput; - -class TestContext : public QObject -{ - Q_OBJECT -private Q_SLOTS: - void cleanup(); - void testCreateFailUdev(); - void testAssignSeat_data(); - void testAssignSeat(); -}; - -void TestContext::cleanup() -{ - delete udev::s_mockUdev; - udev::s_mockUdev = nullptr; -} - -void TestContext::testCreateFailUdev() -{ - // this test verifies that isValid is false if the setup fails - // we create an Udev without a mockUdev - Udev u; - QVERIFY(!(udev*)(u)); - Context context(u); - QVERIFY(!context.isValid()); - // should not have a valid libinput - libinput *libinput = context; - QVERIFY(!libinput); - QVERIFY(!context.assignSeat("testSeat")); - QCOMPARE(context.fileDescriptor(), -1); -} - -void TestContext::testAssignSeat_data() -{ - QTest::addColumn("assignShouldFail"); - QTest::addColumn("expectedValue"); - - QTest::newRow("succeeds") << false << true; - QTest::newRow("fails") << true << false; -} - -void TestContext::testAssignSeat() -{ - // this test verifies the behavior of assignSeat - // setup udev so that we can create a context - udev::s_mockUdev = new udev; - QVERIFY(udev::s_mockUdev); - Udev u; - QVERIFY((udev*)(u)); - Context context(u); - QVERIFY(context.isValid()); - // this should give as a libinput - libinput *libinput = context; - QVERIFY(libinput); - // and now we can assign it - QFETCH(bool, assignShouldFail); - libinput->assignSeatRetVal = assignShouldFail; - QTEST(context.assignSeat("testSeat"), "expectedValue"); - // of course it's not suspended - QVERIFY(!context.isSuspended()); -} - -QTEST_GUILESS_MAIN(TestContext) -#include "context_test.moc" diff --git a/autotests/libinput/mock_udev.cpp b/autotests/libinput/mock_udev.cpp deleted file mode 100644 index 291ee1944a..0000000000 --- a/autotests/libinput/mock_udev.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - KWin - the KDE window manager - This file is part of the KDE project. - - SPDX-FileCopyrightText: 2016 Martin Gräßlin - - SPDX-License-Identifier: GPL-2.0-or-later -*/ -#include "udev.h" - -#include "mock_udev.h" - -udev *udev::s_mockUdev = nullptr; - -namespace KWin -{ - -Udev::Udev() - : m_udev(udev::s_mockUdev) -{ -} - -Udev::~Udev() -{ -} - -} diff --git a/autotests/libinput/mock_udev.h b/autotests/libinput/mock_udev.h deleted file mode 100644 index 8560521b37..0000000000 --- a/autotests/libinput/mock_udev.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - KWin - the KDE window manager - This file is part of the KDE project. - - SPDX-FileCopyrightText: 2016 Martin Gräßlin - - SPDX-License-Identifier: GPL-2.0-or-later -*/ -#ifndef MOCK_UDEV_H -#define MOCK_UDEV_H - -struct udev { - static udev *s_mockUdev; -}; - -#endif -