Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/dont_crash_reinitialize_compositor.cpp
Show All 17 Lines | |||||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | 20 | | |||
21 | #include "kwin_wayland_test.h" | 21 | #include "kwin_wayland_test.h" | ||
22 | 22 | | |||
23 | #include "abstract_client.h" | 23 | #include "abstract_client.h" | ||
24 | #include "composite.h" | 24 | #include "composite.h" | ||
25 | #include "deleted.h" | 25 | #include "deleted.h" | ||
26 | #include "effectloader.h" | ||||
26 | #include "effects.h" | 27 | #include "effects.h" | ||
27 | #include "platform.h" | 28 | #include "platform.h" | ||
28 | #include "screens.h" | 29 | #include "screens.h" | ||
29 | #include "shell_client.h" | 30 | #include "shell_client.h" | ||
30 | #include "wayland_server.h" | 31 | #include "wayland_server.h" | ||
31 | #include "workspace.h" | 32 | #include "workspace.h" | ||
32 | 33 | | |||
34 | #include "effect_builtins.h" | ||||
35 | | ||||
33 | #include <KWayland/Client/surface.h> | 36 | #include <KWayland/Client/surface.h> | ||
34 | #include <KWayland/Client/xdgshell.h> | 37 | #include <KWayland/Client/xdgshell.h> | ||
35 | 38 | | |||
36 | namespace KWin | 39 | namespace KWin | ||
37 | { | 40 | { | ||
38 | 41 | | |||
39 | static const QString s_socketName = QStringLiteral("wayland_test_kwin_dont_crash_reinitialize_compositor-0"); | 42 | static const QString s_socketName = QStringLiteral("wayland_test_kwin_dont_crash_reinitialize_compositor-0"); | ||
40 | 43 | | |||
Show All 18 Lines | 58 | { | |||
59 | qRegisterMetaType<KWin::Deleted *>(); | 62 | qRegisterMetaType<KWin::Deleted *>(); | ||
60 | qRegisterMetaType<KWin::ShellClient *>(); | 63 | qRegisterMetaType<KWin::ShellClient *>(); | ||
61 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | 64 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||
62 | QVERIFY(workspaceCreatedSpy.isValid()); | 65 | QVERIFY(workspaceCreatedSpy.isValid()); | ||
63 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | 66 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | ||
64 | QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); | 67 | QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); | ||
65 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | 68 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | ||
66 | 69 | | |||
70 | auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig); | ||||
71 | KConfigGroup plugins(config, QStringLiteral("Plugins")); | ||||
72 | ScriptedEffectLoader loader; | ||||
73 | const auto builtinNames = BuiltInEffects::availableEffectNames() << loader.listOfKnownEffects(); | ||||
74 | for (const QString &name : builtinNames) { | ||||
75 | plugins.writeEntry(name + QStringLiteral("Enabled"), false); | ||||
76 | } | ||||
77 | config->sync(); | ||||
78 | kwinApp()->setConfig(config); | ||||
79 | | ||||
67 | qputenv("KWIN_COMPOSE", QByteArrayLiteral("O2")); | 80 | qputenv("KWIN_COMPOSE", QByteArrayLiteral("O2")); | ||
68 | qputenv("KWIN_EFFECTS_FORCE_ANIMATIONS", QByteArrayLiteral("1")); | 81 | qputenv("KWIN_EFFECTS_FORCE_ANIMATIONS", QByteArrayLiteral("1")); | ||
69 | 82 | | |||
70 | kwinApp()->start(); | 83 | kwinApp()->start(); | ||
71 | QVERIFY(workspaceCreatedSpy.wait()); | 84 | QVERIFY(workspaceCreatedSpy.wait()); | ||
72 | QCOMPARE(screens()->count(), 2); | 85 | QCOMPARE(screens()->count(), 2); | ||
73 | QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); | 86 | QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); | ||
74 | QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); | 87 | QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); | ||
75 | waylandServer()->initWorkspace(); | 88 | waylandServer()->initWorkspace(); | ||
76 | } | 89 | } | ||
77 | 90 | | |||
78 | void DontCrashReinitializeCompositorTest::init() | 91 | void DontCrashReinitializeCompositorTest::init() | ||
79 | { | 92 | { | ||
80 | QVERIFY(Test::setupWaylandConnection()); | 93 | QVERIFY(Test::setupWaylandConnection()); | ||
81 | } | 94 | } | ||
82 | 95 | | |||
83 | void DontCrashReinitializeCompositorTest::cleanup() | 96 | void DontCrashReinitializeCompositorTest::cleanup() | ||
84 | { | 97 | { | ||
98 | // Unload all effects. | ||||
99 | auto effectsImpl = qobject_cast<EffectsHandlerImpl *>(effects); | ||||
100 | QVERIFY(effectsImpl); | ||||
101 | effectsImpl->unloadAllEffects(); | ||||
102 | QVERIFY(effectsImpl->loadedEffects().isEmpty()); | ||||
103 | | ||||
85 | Test::destroyWaylandConnection(); | 104 | Test::destroyWaylandConnection(); | ||
86 | } | 105 | } | ||
87 | 106 | | |||
88 | void DontCrashReinitializeCompositorTest::testReinitializeCompositor_data() | 107 | void DontCrashReinitializeCompositorTest::testReinitializeCompositor_data() | ||
89 | { | 108 | { | ||
90 | QTest::addColumn<QString>("effectName"); | 109 | QTest::addColumn<QString>("effectName"); | ||
91 | 110 | | |||
92 | QTest::newRow("Fade") << QStringLiteral("kwin4_effect_fade"); | 111 | QTest::newRow("Fade") << QStringLiteral("kwin4_effect_fade"); | ||
93 | QTest::newRow("Glide") << QStringLiteral("glide"); | 112 | QTest::newRow("Glide") << QStringLiteral("glide"); | ||
94 | QTest::newRow("Scale") << QStringLiteral("kwin4_effect_scale"); | 113 | QTest::newRow("Scale") << QStringLiteral("kwin4_effect_scale"); | ||
95 | } | 114 | } | ||
96 | 115 | | |||
97 | void DontCrashReinitializeCompositorTest::testReinitializeCompositor() | 116 | void DontCrashReinitializeCompositorTest::testReinitializeCompositor() | ||
98 | { | 117 | { | ||
99 | // This test verifies that KWin doesn't crash when the compositor settings | 118 | // This test verifies that KWin doesn't crash when the compositor settings | ||
100 | // have been changed while a scripted effect animates the disappearing of | 119 | // have been changed while a scripted effect animates the disappearing of | ||
101 | // a window. | 120 | // a window. | ||
102 | 121 | | |||
103 | // Make sure that we have the right effects ptr. | 122 | // Make sure that we have the right effects ptr. | ||
104 | auto effectsImpl = qobject_cast<EffectsHandlerImpl *>(effects); | 123 | auto effectsImpl = qobject_cast<EffectsHandlerImpl *>(effects); | ||
105 | QVERIFY(effectsImpl); | 124 | QVERIFY(effectsImpl); | ||
106 | 125 | | |||
107 | // Unload all effects. | | |||
108 | effectsImpl->unloadAllEffects(); | | |||
109 | QVERIFY(effectsImpl->loadedEffects().isEmpty()); | | |||
110 | | ||||
111 | // Create the test client. | 126 | // Create the test client. | ||
112 | using namespace KWayland::Client; | 127 | using namespace KWayland::Client; | ||
113 | 128 | | |||
114 | QScopedPointer<Surface> surface(Test::createSurface()); | 129 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
115 | QVERIFY(!surface.isNull()); | 130 | QVERIFY(!surface.isNull()); | ||
116 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | 131 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
117 | QVERIFY(!shellSurface.isNull()); | 132 | QVERIFY(!shellSurface.isNull()); | ||
118 | ShellClient *client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 133 | ShellClient *client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
Show All 32 Lines |