Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/effects/windowgeometry_test.cpp
- This file was added.
1 | /******************************************************************** | ||||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | ||||
3 | This file is part of the KDE project. | ||||
4 | | ||||
5 | Copyright (C) 2017 Martin Flöser <mgraesslin@kde.org> | ||||
6 | | ||||
7 | This program is free software; you can redistribute it and/or modify | ||||
8 | it under the terms of the GNU General Public License as published by | ||||
9 | the Free Software Foundation; either version 2 of the License, or | ||||
10 | (at your option) any later version. | ||||
11 | | ||||
12 | This program is distributed in the hope that it will be useful, | ||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | GNU General Public License for more details. | ||||
16 | | ||||
17 | You should have received a copy of the GNU General Public License | ||||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | *********************************************************************/ | ||||
20 | #include "kwin_wayland_test.h" | ||||
21 | #include "composite.h" | ||||
22 | #include "effects.h" | ||||
23 | #include "effectloader.h" | ||||
24 | #include "cursor.h" | ||||
25 | #include "platform.h" | ||||
26 | #include "shell_client.h" | ||||
27 | #include "wayland_server.h" | ||||
28 | #include "workspace.h" | ||||
29 | #include "effect_builtins.h" | ||||
30 | | ||||
31 | #include <KConfigGroup> | ||||
32 | | ||||
33 | #include <KWayland/Client/buffer.h> | ||||
34 | #include <KWayland/Client/shell.h> | ||||
35 | #include <KWayland/Client/surface.h> | ||||
36 | | ||||
37 | using namespace KWin; | ||||
38 | using namespace KWayland::Client; | ||||
39 | static const QString s_socketName = QStringLiteral("wayland_test_effects_windowgeometry-0"); | ||||
40 | | ||||
41 | class WindowGeometryTest : public QObject | ||||
42 | { | ||||
43 | Q_OBJECT | ||||
44 | private Q_SLOTS: | ||||
45 | void initTestCase(); | ||||
46 | void init(); | ||||
47 | void cleanup(); | ||||
48 | | ||||
49 | void testStartup(); | ||||
50 | }; | ||||
51 | | ||||
52 | void WindowGeometryTest::initTestCase() | ||||
53 | { | ||||
54 | qRegisterMetaType<KWin::ShellClient*>(); | ||||
55 | qRegisterMetaType<KWin::AbstractClient*>(); | ||||
56 | qRegisterMetaType<KWin::Effect*>(); | ||||
57 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||||
58 | QVERIFY(workspaceCreatedSpy.isValid()); | ||||
59 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | ||||
60 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | ||||
61 | | ||||
62 | // disable all effects - we don't want to have it interact with the rendering | ||||
63 | auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig); | ||||
64 | KConfigGroup plugins(config, QStringLiteral("Plugins")); | ||||
65 | ScriptedEffectLoader loader; | ||||
66 | const auto builtinNames = BuiltInEffects::availableEffectNames() << loader.listOfKnownEffects(); | ||||
67 | for (QString name : builtinNames) { | ||||
68 | plugins.writeEntry(name + QStringLiteral("Enabled"), false); | ||||
69 | } | ||||
70 | plugins.writeEntry(BuiltInEffects::nameForEffect(BuiltInEffect::WindowGeometry) + QStringLiteral("Enabled"), true); | ||||
71 | | ||||
72 | config->sync(); | ||||
73 | kwinApp()->setConfig(config); | ||||
74 | | ||||
75 | qputenv("KWIN_EFFECTS_FORCE_ANIMATIONS", "1"); | ||||
76 | kwinApp()->start(); | ||||
77 | QVERIFY(workspaceCreatedSpy.wait()); | ||||
78 | QVERIFY(KWin::Compositor::self()); | ||||
79 | } | ||||
80 | | ||||
81 | void WindowGeometryTest::init() | ||||
82 | { | ||||
83 | QVERIFY(Test::setupWaylandConnection()); | ||||
84 | } | ||||
85 | | ||||
86 | void WindowGeometryTest::cleanup() | ||||
87 | { | ||||
88 | Test::destroyWaylandConnection(); | ||||
89 | } | ||||
90 | | ||||
91 | void WindowGeometryTest::testStartup() | ||||
92 | { | ||||
93 | // just a test to load the effect to verify it doesn't crash | ||||
94 | EffectsHandlerImpl *e = static_cast<EffectsHandlerImpl*>(effects); | ||||
95 | QVERIFY(e->isEffectLoaded(BuiltInEffects::nameForEffect(BuiltInEffect::WindowGeometry))); | ||||
96 | } | ||||
97 | | ||||
98 | WAYLANDTEST_MAIN(WindowGeometryTest) | ||||
99 | #include "windowgeometry_test.moc" |