From 5903c5be0972a64042924b0421e381a42d8b68f9 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Wed, 2 Sep 2020 17:08:28 +0200 Subject: [PATCH] Fix testScreenEdges for good Don't call kwinApp, because we are not on one. The correct way to mock the geometries is by using the MockScreens, which is already used in this test. --- autotests/test_screen_edges.cpp | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/autotests/test_screen_edges.cpp b/autotests/test_screen_edges.cpp index a0adfdeb5e..28ec472832 100644 --- a/autotests/test_screen_edges.cpp +++ b/autotests/test_screen_edges.cpp @@ -123,6 +123,8 @@ void TestScreenEdges::init() new MockWorkspace(this); auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig); Screens::create(); + QSignalSpy sp(screens(), &MockScreens::changed); + QVERIFY(sp.wait()); auto vd = VirtualDesktopManager::create(); vd->setConfig(config); @@ -591,15 +593,12 @@ void TestScreenEdges::testOverlappingEdges() QFETCH(QRect, geo1); QFETCH(QRect, geo2); - QVector geometries{{geo1, geo2}}; - QMetaObject::invokeMethod(kwinApp()->platform(), - "setVirtualOutputs", - Qt::DirectConnection, - Q_ARG(int, geometries.count()), - Q_ARG(QVector, geometries), - Q_ARG(QVector, QVector(geometries.count(), 1)) - ); + MockScreens* mockScreens = static_cast(screens()); + QSignalSpy sp(mockScreens, &MockScreens::changed); + mockScreens->setGeometries({geo1, geo2}); + QVERIFY(sp.wait()); + QCOMPARE(screens()->count(), 2); auto screenEdges = ScreenEdges::self(); screenEdges->init(); } @@ -630,16 +629,6 @@ void TestScreenEdges::testPushBack() config->group("Windows").writeEntry("ElectricBorderPushbackPixels", pushback); config->sync(); - QVector geometries{{QRect{0, 0, 1024, 768}, QRect{200, 768, 1024, 768}}}; - QMetaObject::invokeMethod(kwinApp()->platform(), - "setVirtualOutputs", - Qt::DirectConnection, - Q_ARG(int, geometries.count()), - Q_ARG(QVector, geometries), - Q_ARG(QVector, QVector(geometries.count(), 1)) - ); - - auto s = ScreenEdges::self(); s->setConfig(config); s->init();