Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/virtual_desktop_test.cpp
Show First 20 Lines • Show All 126 Lines • ▼ Show 20 Line(s) | 93 | { | |||
---|---|---|---|---|---|
127 | VirtualDesktopManager::self()->setCurrent(1); | 127 | VirtualDesktopManager::self()->setCurrent(1); | ||
128 | currentDesktop = Xcb::Property(0, kwinApp()->x11RootWindow(), currentDesktopAtom, XCB_ATOM_CARDINAL, 0, 1); | 128 | currentDesktop = Xcb::Property(0, kwinApp()->x11RootWindow(), currentDesktopAtom, XCB_ATOM_CARDINAL, 0, 1); | ||
129 | QCOMPARE(currentDesktop.value(0, &ok), 0); | 129 | QCOMPARE(currentDesktop.value(0, &ok), 0); | ||
130 | QVERIFY(ok); | 130 | QVERIFY(ok); | ||
131 | } | 131 | } | ||
132 | 132 | | |||
133 | void VirtualDesktopTest::testLastDesktopRemoved_data() | 133 | void VirtualDesktopTest::testLastDesktopRemoved_data() | ||
134 | { | 134 | { | ||
135 | QTest::addColumn<Test::ShellSurfaceType>("type"); | 135 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
136 | 136 | | |||
137 | QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell; | 137 | QTest::newRow("xdgShellV5") << Test::XdgShellSurfaceType::XdgShellV5; | ||
138 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | 138 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
139 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | 139 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
140 | QTest::newRow("xdgWmBase") << Test::ShellSurfaceType::XdgShellStable; | | |||
141 | } | 140 | } | ||
142 | 141 | | |||
143 | void VirtualDesktopTest::testLastDesktopRemoved() | 142 | void VirtualDesktopTest::testLastDesktopRemoved() | ||
144 | { | 143 | { | ||
145 | // first create a new desktop | 144 | // first create a new desktop | ||
146 | QCOMPARE(VirtualDesktopManager::self()->count(), 1u); | 145 | QCOMPARE(VirtualDesktopManager::self()->count(), 1u); | ||
147 | VirtualDesktopManager::self()->setCount(2); | 146 | VirtualDesktopManager::self()->setCount(2); | ||
148 | QCOMPARE(VirtualDesktopManager::self()->count(), 2u); | 147 | QCOMPARE(VirtualDesktopManager::self()->count(), 2u); | ||
149 | 148 | | |||
150 | // switch to last desktop | 149 | // switch to last desktop | ||
151 | VirtualDesktopManager::self()->setCurrent(VirtualDesktopManager::self()->desktops().last()); | 150 | VirtualDesktopManager::self()->setCurrent(VirtualDesktopManager::self()->desktops().last()); | ||
152 | QCOMPARE(VirtualDesktopManager::self()->current(), 2u); | 151 | QCOMPARE(VirtualDesktopManager::self()->current(), 2u); | ||
153 | 152 | | |||
154 | // now create a window on this desktop | 153 | // now create a window on this desktop | ||
155 | QScopedPointer<Surface> surface(Test::createSurface()); | 154 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
156 | QFETCH(Test::ShellSurfaceType, type); | 155 | QFETCH(Test::XdgShellSurfaceType, type); | ||
157 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | 156 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
158 | auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 157 | auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
159 | 158 | | |||
160 | QVERIFY(client); | 159 | QVERIFY(client); | ||
161 | QCOMPARE(client->desktop(), 2); | 160 | QCOMPARE(client->desktop(), 2); | ||
162 | QSignalSpy desktopPresenceChangedSpy(client, &ShellClient::desktopPresenceChanged); | 161 | QSignalSpy desktopPresenceChangedSpy(client, &ShellClient::desktopPresenceChanged); | ||
163 | QVERIFY(desktopPresenceChangedSpy.isValid()); | 162 | QVERIFY(desktopPresenceChangedSpy.isValid()); | ||
164 | 163 | | |||
165 | QCOMPARE(client->desktops().count(), 1u); | 164 | QCOMPARE(client->desktops().count(), 1u); | ||
166 | QCOMPARE(VirtualDesktopManager::self()->currentDesktop(), client->desktops().first()); | 165 | QCOMPARE(VirtualDesktopManager::self()->currentDesktop(), client->desktops().first()); | ||
167 | 166 | | |||
168 | // and remove last desktop | 167 | // and remove last desktop | ||
169 | VirtualDesktopManager::self()->setCount(1); | 168 | VirtualDesktopManager::self()->setCount(1); | ||
170 | QCOMPARE(VirtualDesktopManager::self()->count(), 1u); | 169 | QCOMPARE(VirtualDesktopManager::self()->count(), 1u); | ||
171 | // now the client should be moved as well | 170 | // now the client should be moved as well | ||
172 | QTRY_COMPARE(desktopPresenceChangedSpy.count(), 1); | 171 | QTRY_COMPARE(desktopPresenceChangedSpy.count(), 1); | ||
173 | QCOMPARE(client->desktop(), 1); | 172 | QCOMPARE(client->desktop(), 1); | ||
174 | 173 | | |||
175 | QCOMPARE(client->desktops().count(), 1u); | 174 | QCOMPARE(client->desktops().count(), 1u); | ||
176 | QCOMPARE(VirtualDesktopManager::self()->currentDesktop(), client->desktops().first()); | 175 | QCOMPARE(VirtualDesktopManager::self()->currentDesktop(), client->desktops().first()); | ||
177 | } | 176 | } | ||
178 | 177 | | |||
179 | void VirtualDesktopTest::testWindowOnMultipleDesktops_data() | 178 | void VirtualDesktopTest::testWindowOnMultipleDesktops_data() | ||
180 | { | 179 | { | ||
181 | QTest::addColumn<Test::ShellSurfaceType>("type"); | 180 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
182 | 181 | | |||
183 | QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell; | 182 | QTest::newRow("xdgShellV5") << Test::XdgShellSurfaceType::XdgShellV5; | ||
184 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | 183 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
185 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | 184 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
186 | QTest::newRow("xdgWmBase") << Test::ShellSurfaceType::XdgShellStable; | | |||
187 | } | 185 | } | ||
188 | 186 | | |||
189 | void VirtualDesktopTest::testWindowOnMultipleDesktops() | 187 | void VirtualDesktopTest::testWindowOnMultipleDesktops() | ||
190 | { | 188 | { | ||
191 | // first create two new desktops | 189 | // first create two new desktops | ||
192 | QCOMPARE(VirtualDesktopManager::self()->count(), 1u); | 190 | QCOMPARE(VirtualDesktopManager::self()->count(), 1u); | ||
193 | VirtualDesktopManager::self()->setCount(3); | 191 | VirtualDesktopManager::self()->setCount(3); | ||
194 | QCOMPARE(VirtualDesktopManager::self()->count(), 3u); | 192 | QCOMPARE(VirtualDesktopManager::self()->count(), 3u); | ||
195 | 193 | | |||
196 | // switch to last desktop | 194 | // switch to last desktop | ||
197 | VirtualDesktopManager::self()->setCurrent(VirtualDesktopManager::self()->desktops().last()); | 195 | VirtualDesktopManager::self()->setCurrent(VirtualDesktopManager::self()->desktops().last()); | ||
198 | QCOMPARE(VirtualDesktopManager::self()->current(), 3u); | 196 | QCOMPARE(VirtualDesktopManager::self()->current(), 3u); | ||
199 | 197 | | |||
200 | // now create a window on this desktop | 198 | // now create a window on this desktop | ||
201 | QScopedPointer<Surface> surface(Test::createSurface()); | 199 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
202 | QFETCH(Test::ShellSurfaceType, type); | 200 | QFETCH(Test::XdgShellSurfaceType, type); | ||
203 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | 201 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
204 | auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 202 | auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
205 | 203 | | |||
206 | QVERIFY(client); | 204 | QVERIFY(client); | ||
207 | QCOMPARE(client->desktop(), 3u); | 205 | QCOMPARE(client->desktop(), 3u); | ||
208 | QSignalSpy desktopPresenceChangedSpy(client, &ShellClient::desktopPresenceChanged); | 206 | QSignalSpy desktopPresenceChangedSpy(client, &ShellClient::desktopPresenceChanged); | ||
209 | QVERIFY(desktopPresenceChangedSpy.isValid()); | 207 | QVERIFY(desktopPresenceChangedSpy.isValid()); | ||
210 | 208 | | |||
211 | QCOMPARE(client->desktops().count(), 1u); | 209 | QCOMPARE(client->desktops().count(), 1u); | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | |||||
263 | client->leaveDesktop(VirtualDesktopManager::self()->desktopForX11Id(3)); | 261 | client->leaveDesktop(VirtualDesktopManager::self()->desktopForX11Id(3)); | ||
264 | QVERIFY(client->isOnDesktop(1)); | 262 | QVERIFY(client->isOnDesktop(1)); | ||
265 | QVERIFY(client->isOnDesktop(2)); | 263 | QVERIFY(client->isOnDesktop(2)); | ||
266 | QCOMPARE(client->desktops().count(), 2u); | 264 | QCOMPARE(client->desktops().count(), 2u); | ||
267 | } | 265 | } | ||
268 | 266 | | |||
269 | void VirtualDesktopTest::testRemoveDesktopWithWindow_data() | 267 | void VirtualDesktopTest::testRemoveDesktopWithWindow_data() | ||
270 | { | 268 | { | ||
271 | QTest::addColumn<Test::ShellSurfaceType>("type"); | 269 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
272 | 270 | | |||
273 | QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell; | 271 | QTest::newRow("xdgShellV5") << Test::XdgShellSurfaceType::XdgShellV5; | ||
274 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | 272 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
275 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | 273 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
276 | QTest::newRow("xdgWmBase") << Test::ShellSurfaceType::XdgShellStable; | | |||
277 | } | 274 | } | ||
278 | 275 | | |||
279 | void VirtualDesktopTest::testRemoveDesktopWithWindow() | 276 | void VirtualDesktopTest::testRemoveDesktopWithWindow() | ||
280 | { | 277 | { | ||
281 | // first create two new desktops | 278 | // first create two new desktops | ||
282 | QCOMPARE(VirtualDesktopManager::self()->count(), 1u); | 279 | QCOMPARE(VirtualDesktopManager::self()->count(), 1u); | ||
283 | VirtualDesktopManager::self()->setCount(3); | 280 | VirtualDesktopManager::self()->setCount(3); | ||
284 | QCOMPARE(VirtualDesktopManager::self()->count(), 3u); | 281 | QCOMPARE(VirtualDesktopManager::self()->count(), 3u); | ||
285 | 282 | | |||
286 | // switch to last desktop | 283 | // switch to last desktop | ||
287 | VirtualDesktopManager::self()->setCurrent(VirtualDesktopManager::self()->desktops().last()); | 284 | VirtualDesktopManager::self()->setCurrent(VirtualDesktopManager::self()->desktops().last()); | ||
288 | QCOMPARE(VirtualDesktopManager::self()->current(), 3u); | 285 | QCOMPARE(VirtualDesktopManager::self()->current(), 3u); | ||
289 | 286 | | |||
290 | // now create a window on this desktop | 287 | // now create a window on this desktop | ||
291 | QScopedPointer<Surface> surface(Test::createSurface()); | 288 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
292 | QFETCH(Test::ShellSurfaceType, type); | 289 | QFETCH(Test::XdgShellSurfaceType, type); | ||
293 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | 290 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
294 | auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 291 | auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
295 | 292 | | |||
296 | QVERIFY(client); | 293 | QVERIFY(client); | ||
297 | QCOMPARE(client->desktop(), 3u); | 294 | QCOMPARE(client->desktop(), 3u); | ||
298 | QSignalSpy desktopPresenceChangedSpy(client, &ShellClient::desktopPresenceChanged); | 295 | QSignalSpy desktopPresenceChangedSpy(client, &ShellClient::desktopPresenceChanged); | ||
299 | QVERIFY(desktopPresenceChangedSpy.isValid()); | 296 | QVERIFY(desktopPresenceChangedSpy.isValid()); | ||
300 | 297 | | |||
301 | QCOMPARE(client->desktops().count(), 1u); | 298 | QCOMPARE(client->desktops().count(), 1u); | ||
Show All 34 Lines |