Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/shell_client_test.cpp
Show All 13 Lines | |||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 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/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "kwin_wayland_test.h" | 20 | #include "kwin_wayland_test.h" | ||
21 | #include "cursor.h" | 21 | #include "cursor.h" | ||
22 | #include "effects.h" | ||||
22 | #include "platform.h" | 23 | #include "platform.h" | ||
23 | #include "shell_client.h" | 24 | #include "shell_client.h" | ||
24 | #include "screens.h" | 25 | #include "screens.h" | ||
25 | #include "wayland_server.h" | 26 | #include "wayland_server.h" | ||
26 | #include "workspace.h" | 27 | #include "workspace.h" | ||
27 | 28 | | |||
28 | #include <KWayland/Client/connection_thread.h> | 29 | #include <KWayland/Client/connection_thread.h> | ||
29 | #include <KWayland/Client/compositor.h> | 30 | #include <KWayland/Client/compositor.h> | ||
Show All 11 Lines | |||||
41 | { | 42 | { | ||
42 | Q_OBJECT | 43 | Q_OBJECT | ||
43 | private Q_SLOTS: | 44 | private Q_SLOTS: | ||
44 | void initTestCase(); | 45 | void initTestCase(); | ||
45 | void init(); | 46 | void init(); | ||
46 | void cleanup(); | 47 | void cleanup(); | ||
47 | 48 | | |||
48 | void testMapUnmapMap(); | 49 | void testMapUnmapMap(); | ||
50 | void testDesktopPresenceChanged(); | ||||
49 | }; | 51 | }; | ||
50 | 52 | | |||
51 | void TestShellClient::initTestCase() | 53 | void TestShellClient::initTestCase() | ||
52 | { | 54 | { | ||
53 | qRegisterMetaType<KWin::ShellClient*>(); | 55 | qRegisterMetaType<KWin::ShellClient*>(); | ||
54 | qRegisterMetaType<KWin::AbstractClient*>(); | 56 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
55 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | 57 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||
56 | QVERIFY(workspaceCreatedSpy.isValid()); | 58 | QVERIFY(workspaceCreatedSpy.isValid()); | ||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | 85 | { | |||
126 | QVERIFY(windowClosedSpy.isEmpty()); | 128 | QVERIFY(windowClosedSpy.isEmpty()); | ||
127 | 129 | | |||
128 | shellSurface.reset(); | 130 | shellSurface.reset(); | ||
129 | surface.reset(); | 131 | surface.reset(); | ||
130 | QVERIFY(windowClosedSpy.wait()); | 132 | QVERIFY(windowClosedSpy.wait()); | ||
131 | QCOMPARE(windowClosedSpy.count(), 1); | 133 | QCOMPARE(windowClosedSpy.count(), 1); | ||
132 | } | 134 | } | ||
133 | 135 | | |||
136 | void TestShellClient::testDesktopPresenceChanged() | ||||
137 | { | ||||
138 | // this test verifies that the desktop presence changed signals are properly emitted | ||||
139 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
140 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | ||||
141 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||||
142 | QVERIFY(c); | ||||
143 | QCOMPARE(c->desktop(), 1); | ||||
144 | effects->setNumberOfDesktops(4); | ||||
145 | QSignalSpy desktopPresenceChangedClientSpy(c, &ShellClient::desktopPresenceChanged); | ||||
146 | QVERIFY(desktopPresenceChangedClientSpy.isValid()); | ||||
147 | QSignalSpy desktopPresenceChangedWorkspaceSpy(workspace(), &Workspace::desktopPresenceChanged); | ||||
148 | QVERIFY(desktopPresenceChangedWorkspaceSpy.isValid()); | ||||
149 | QSignalSpy desktopPresenceChangedEffectsSpy(effects, &EffectsHandler::desktopPresenceChanged); | ||||
150 | QVERIFY(desktopPresenceChangedEffectsSpy.isValid()); | ||||
151 | | ||||
152 | // let's change the desktop | ||||
153 | workspace()->sendClientToDesktop(c, 2, false); | ||||
154 | QCOMPARE(c->desktop(), 2); | ||||
155 | QCOMPARE(desktopPresenceChangedClientSpy.count(), 1); | ||||
156 | QCOMPARE(desktopPresenceChangedWorkspaceSpy.count(), 1); | ||||
157 | // effects is delayed by one cycle | ||||
158 | QCOMPARE(desktopPresenceChangedEffectsSpy.count(), 0); | ||||
159 | QVERIFY(desktopPresenceChangedEffectsSpy.wait()); | ||||
160 | QCOMPARE(desktopPresenceChangedEffectsSpy.count(), 1); | ||||
161 | | ||||
162 | // verify the arguments | ||||
163 | QCOMPARE(desktopPresenceChangedClientSpy.first().at(0).value<AbstractClient*>(), c); | ||||
164 | QCOMPARE(desktopPresenceChangedClientSpy.first().at(1).toInt(), 1); | ||||
165 | QCOMPARE(desktopPresenceChangedWorkspaceSpy.first().at(0).value<AbstractClient*>(), c); | ||||
166 | QCOMPARE(desktopPresenceChangedWorkspaceSpy.first().at(1).toInt(), 1); | ||||
167 | QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(0).value<EffectWindow*>(), c->effectWindow()); | ||||
168 | QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(1).toInt(), 1); | ||||
169 | QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(2).toInt(), 2); | ||||
170 | } | ||||
171 | | ||||
134 | WAYLANDTEST_MAIN(TestShellClient) | 172 | WAYLANDTEST_MAIN(TestShellClient) | ||
135 | #include "shell_client_test.moc" | 173 | #include "shell_client_test.moc" |