Fix testScreens

This commit is contained in:
Xaver Hugl 2021-04-26 16:07:58 +02:00
parent b6231aca92
commit 2aae299eba

View file

@ -99,19 +99,19 @@ void ScreensTest::cleanup()
void ScreensTest::testCurrentFollowsMouse() void ScreensTest::testCurrentFollowsMouse()
{ {
QVERIFY(screens()->isCurrentFollowsMouse());
screens()->setCurrentFollowsMouse(false);
QVERIFY(!screens()->isCurrentFollowsMouse()); QVERIFY(!screens()->isCurrentFollowsMouse());
screens()->setCurrentFollowsMouse(true);
QVERIFY(screens()->isCurrentFollowsMouse());
// setting to same should not do anything // setting to same should not do anything
screens()->setCurrentFollowsMouse(true); screens()->setCurrentFollowsMouse(false);
QVERIFY(screens()->isCurrentFollowsMouse()); QVERIFY(!screens()->isCurrentFollowsMouse());
// setting back to other value // setting back to other value
screens()->setCurrentFollowsMouse(false); screens()->setCurrentFollowsMouse(true);
QVERIFY(!screens()->isCurrentFollowsMouse()); QVERIFY(screens()->isCurrentFollowsMouse());
// setting to same should not do anything // setting to same should not do anything
screens()->setCurrentFollowsMouse(false); screens()->setCurrentFollowsMouse(true);
QVERIFY(!screens()->isCurrentFollowsMouse()); QVERIFY(screens()->isCurrentFollowsMouse());
} }
void ScreensTest::testReconfigure_data() void ScreensTest::testReconfigure_data()
@ -129,20 +129,10 @@ void ScreensTest::testReconfigure_data()
void ScreensTest::testReconfigure() void ScreensTest::testReconfigure()
{ {
screens()->reconfigure(); screens()->reconfigure();
QVERIFY(!screens()->isCurrentFollowsMouse()); QVERIFY(screens()->isCurrentFollowsMouse());
QFETCH(QString, focusPolicy);
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
config->group("Windows").writeEntry("FocusPolicy", focusPolicy);
config->group("Windows").sync();
config->sync();
screens()->setConfig(config);
screens()->reconfigure();
QTEST(screens()->isCurrentFollowsMouse(), "expectedDefault");
QFETCH(bool, setting); QFETCH(bool, setting);
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
config->group("Windows").writeEntry("ActiveMouseScreen", setting); config->group("Windows").writeEntry("ActiveMouseScreen", setting);
config->sync(); config->sync();
screens()->reconfigure(); screens()->reconfigure();
@ -240,6 +230,7 @@ void ScreensTest::testCurrent()
QVERIFY(currentChangedSpy.isValid()); QVERIFY(currentChangedSpy.isValid());
QFETCH(int, current); QFETCH(int, current);
screens()->setCurrentFollowsMouse(false);
screens()->setCurrent(current); screens()->setCurrent(current);
QCOMPARE(screens()->current(), current); QCOMPARE(screens()->current(), current);
QTEST(!currentChangedSpy.isEmpty(), "signal"); QTEST(!currentChangedSpy.isEmpty(), "signal");
@ -250,6 +241,8 @@ void ScreensTest::testCurrentClient()
QSignalSpy currentChangedSpy(screens(), &Screens::currentChanged); QSignalSpy currentChangedSpy(screens(), &Screens::currentChanged);
QVERIFY(currentChangedSpy.isValid()); QVERIFY(currentChangedSpy.isValid());
screens()->setCurrentFollowsMouse(false);
// create a test window // create a test window
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface()); QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
QScopedPointer<KWayland::Client::XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); QScopedPointer<KWayland::Client::XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data()));
@ -331,6 +324,8 @@ void ScreensTest::testCurrentPoint()
Q_ARG(int, geometries.count()), Q_ARG(QVector<QRect>, geometries)); Q_ARG(int, geometries.count()), Q_ARG(QVector<QRect>, geometries));
QVERIFY(changedSpy.wait()); QVERIFY(changedSpy.wait());
screens()->setCurrentFollowsMouse(false);
QFETCH(QPoint, cursorPos); QFETCH(QPoint, cursorPos);
screens()->setCurrent(cursorPos); screens()->setCurrent(cursorPos);
QTEST(screens()->current(), "expected"); QTEST(screens()->current(), "expected");