Commit d345878b authored by Martin Flöser's avatar Martin Flöser

[autotests] Add Q_CONSTRUCTOR_FUNCTION to X11 specific tests to force xcb

The X11 specific tests need to run on QT_QPA_PLATFORM xcb otherwise
they will crash. To enforce this without having to replace QTEST_MAIN
a Q_CONSTRUCTOR_FUNCTION is used to invoke a function which does nothing
except setting the env variable.
parent 66c61adb
......@@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QLoggingCategory>
#include <QX11Info>
#include "../testutils.h"
#include "../../libkwineffects/kwinxrenderutils.h"
class BlendPictureTest : public QObject
......@@ -55,5 +56,6 @@ void BlendPictureTest::testDontCrashOnTeardown()
Q_UNUSED(picture2)
}
Q_CONSTRUCTOR_FUNCTION(forceXcb)
QTEST_MAIN(BlendPictureTest)
#include "blendpicture_test.moc"
......@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "test_tabbox_clientmodel.h"
#include "mock_tabboxhandler.h"
#include "clientmodel.h"
#include "../testutils.h"
#include <QtTest/QtTest>
#include <QX11Info>
......@@ -89,4 +90,5 @@ void TestTabBoxClientModel::testCreateClientListActiveClientNotInFocusChain()
QCOMPARE(clientModel->rowCount(), 1);
}
Q_CONSTRUCTOR_FUNCTION(forceXcb)
QTEST_MAIN(TestTabBoxClientModel)
......@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "mock_tabboxhandler.h"
#include "clientmodel.h"
#include "../testutils.h"
#include <QtTest/QtTest>
#include <QX11Info>
......@@ -56,6 +57,7 @@ void TestTabBoxHandler::testDontCrashUpdateOutlineNullClient()
tabboxhandler.show();
}
Q_CONSTRUCTOR_FUNCTION(forceXcb)
QTEST_MAIN(TestTabBoxHandler)
#include "test_tabbox_handler.moc"
......@@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "../effects/effect_builtins.h"
#include "mock_effectshandler.h"
#include "../scripting/scriptedeffect.h" // for mocking ScriptedEffect::create
#include "testutils.h"
// KDE
#include <KConfig>
#include <KConfigGroup>
......@@ -563,5 +564,6 @@ void TestBuiltInEffectLoader::testLoadAllEffects()
QCOMPARE(loadedEffects.at(1), QStringLiteral("mouseclick"));
}
Q_CONSTRUCTOR_FUNCTION(forceXcb)
QTEST_MAIN(TestBuiltInEffectLoader)
#include "test_builtin_effectloader.moc"
......@@ -151,5 +151,6 @@ void TestClientMachine::emptyHostName()
QCOMPARE(spy.isEmpty(), false);
}
Q_CONSTRUCTOR_FUNCTION(forceXcb)
QTEST_MAIN(TestClientMachine)
#include "test_client_machine.moc"
......@@ -30,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "mock_client.h"
#include "mock_screens.h"
#include "mock_workspace.h"
#include "testutils.h"
// Frameworks
#include <KConfigGroup>
// Qt
......@@ -861,5 +862,6 @@ void TestScreenEdges::testClientEdge()
QCOMPARE(Cursor::pos(), QPoint(1, 50));
}
Q_CONSTRUCTOR_FUNCTION(forceXcb)
QTEST_MAIN(TestScreenEdges)
#include "test_screen_edges.moc"
......@@ -371,5 +371,6 @@ void TestXcbSizeHints::geometryHintsBeforeRead()
QCOMPARE(hints.windowGravity(), XCB_GRAVITY_NORTH_WEST);
}
Q_CONSTRUCTOR_FUNCTION(forceXcb)
QTEST_MAIN(TestXcbSizeHints)
#include "test_xcb_size_hints.moc"
......@@ -207,5 +207,6 @@ void TestXcbWindow::destroyNotManaged()
QVERIFY(attribs);
}
Q_CONSTRUCTOR_FUNCTION(forceXcb)
QTEST_MAIN(TestXcbWindow)
#include "test_xcb_window.moc"
......@@ -525,5 +525,6 @@ void TestXcbWrapper::testMotif()
QTEST(hints.close(), "expectedClose");
}
Q_CONSTRUCTOR_FUNCTION(forceXcb)
QTEST_MAIN(TestXcbWrapper)
#include "test_xcb_wrapper.moc"
......@@ -24,6 +24,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// XCB
#include <xcb/xcb.h>
namespace {
static void forceXcb() {
qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("xcb"));
}
}
namespace KWin {
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment