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()
{
QVERIFY(screens()->isCurrentFollowsMouse());
screens()->setCurrentFollowsMouse(false);
QVERIFY(!screens()->isCurrentFollowsMouse());
screens()->setCurrentFollowsMouse(true);
QVERIFY(screens()->isCurrentFollowsMouse());
// setting to same should not do anything
screens()->setCurrentFollowsMouse(true);
QVERIFY(screens()->isCurrentFollowsMouse());
screens()->setCurrentFollowsMouse(false);
QVERIFY(!screens()->isCurrentFollowsMouse());
// setting back to other value
screens()->setCurrentFollowsMouse(false);
QVERIFY(!screens()->isCurrentFollowsMouse());
screens()->setCurrentFollowsMouse(true);
QVERIFY(screens()->isCurrentFollowsMouse());
// setting to same should not do anything
screens()->setCurrentFollowsMouse(false);
QVERIFY(!screens()->isCurrentFollowsMouse());
screens()->setCurrentFollowsMouse(true);
QVERIFY(screens()->isCurrentFollowsMouse());
}
void ScreensTest::testReconfigure_data()
@ -129,20 +129,10 @@ void ScreensTest::testReconfigure_data()
void ScreensTest::testReconfigure()
{
screens()->reconfigure();
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");
QVERIFY(screens()->isCurrentFollowsMouse());
QFETCH(bool, setting);
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
config->group("Windows").writeEntry("ActiveMouseScreen", setting);
config->sync();
screens()->reconfigure();
@ -240,6 +230,7 @@ void ScreensTest::testCurrent()
QVERIFY(currentChangedSpy.isValid());
QFETCH(int, current);
screens()->setCurrentFollowsMouse(false);
screens()->setCurrent(current);
QCOMPARE(screens()->current(), current);
QTEST(!currentChangedSpy.isEmpty(), "signal");
@ -250,6 +241,8 @@ void ScreensTest::testCurrentClient()
QSignalSpy currentChangedSpy(screens(), &Screens::currentChanged);
QVERIFY(currentChangedSpy.isValid());
screens()->setCurrentFollowsMouse(false);
// create a test window
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
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));
QVERIFY(changedSpy.wait());
screens()->setCurrentFollowsMouse(false);
QFETCH(QPoint, cursorPos);
screens()->setCurrent(cursorPos);
QTEST(screens()->current(), "expected");