Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/idle_inhibition_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 "platform.h" | 21 | #include "platform.h" | ||
22 | #include "shell_client.h" | 22 | #include "xdgshellclient.h" | ||
23 | #include "wayland_server.h" | 23 | #include "wayland_server.h" | ||
24 | #include "workspace.h" | 24 | #include "workspace.h" | ||
25 | 25 | | |||
26 | #include <KWayland/Client/idleinhibit.h> | 26 | #include <KWayland/Client/idleinhibit.h> | ||
27 | #include <KWayland/Client/surface.h> | 27 | #include <KWayland/Client/surface.h> | ||
28 | #include <KWayland/Client/xdgshell.h> | 28 | #include <KWayland/Client/xdgshell.h> | ||
29 | 29 | | |||
30 | #include <KWayland/Server/display.h> | 30 | #include <KWayland/Server/display.h> | ||
Show All 18 Lines | 42 | private Q_SLOTS: | |||
49 | void testDontInhibitWhenNotOnCurrentDesktop(); | 49 | void testDontInhibitWhenNotOnCurrentDesktop(); | ||
50 | void testDontInhibitWhenMinimized(); | 50 | void testDontInhibitWhenMinimized(); | ||
51 | void testDontInhibitWhenUnmapped(); | 51 | void testDontInhibitWhenUnmapped(); | ||
52 | void testDontInhibitWhenLeftCurrentDesktop(); | 52 | void testDontInhibitWhenLeftCurrentDesktop(); | ||
53 | }; | 53 | }; | ||
54 | 54 | | |||
55 | void TestIdleInhibition::initTestCase() | 55 | void TestIdleInhibition::initTestCase() | ||
56 | { | 56 | { | ||
57 | qRegisterMetaType<KWin::ShellClient*>(); | 57 | qRegisterMetaType<KWin::XdgShellClient *>(); | ||
58 | qRegisterMetaType<KWin::AbstractClient*>(); | 58 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
59 | 59 | | |||
60 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | 60 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||
61 | QVERIFY(workspaceCreatedSpy.isValid()); | 61 | QVERIFY(workspaceCreatedSpy.isValid()); | ||
62 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | 62 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | ||
63 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | 63 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | ||
64 | QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); | 64 | QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); | ||
65 | 65 | | |||
▲ Show 20 Lines • Show All 197 Lines • ▼ Show 20 Line(s) | 241 | { | |||
263 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 263 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
264 | QVERIFY(c); | 264 | QVERIFY(c); | ||
265 | 265 | | |||
266 | // This should inhibit our server object. | 266 | // This should inhibit our server object. | ||
267 | QVERIFY(idle->isInhibited()); | 267 | QVERIFY(idle->isInhibited()); | ||
268 | QCOMPARE(inhibitedSpy.count(), 1); | 268 | QCOMPARE(inhibitedSpy.count(), 1); | ||
269 | 269 | | |||
270 | // Unmap the client. | 270 | // Unmap the client. | ||
271 | QSignalSpy hiddenSpy(c, &ShellClient::windowHidden); | 271 | QSignalSpy hiddenSpy(c, &XdgShellClient::windowHidden); | ||
272 | QVERIFY(hiddenSpy.isValid()); | 272 | QVERIFY(hiddenSpy.isValid()); | ||
273 | surface->attachBuffer(Buffer::Ptr()); | 273 | surface->attachBuffer(Buffer::Ptr()); | ||
274 | surface->commit(Surface::CommitFlag::None); | 274 | surface->commit(Surface::CommitFlag::None); | ||
275 | QVERIFY(hiddenSpy.wait()); | 275 | QVERIFY(hiddenSpy.wait()); | ||
276 | 276 | | |||
277 | // The surface is no longer visible, so the compositor don't have to honor the | 277 | // The surface is no longer visible, so the compositor don't have to honor the | ||
278 | // idle inhibitor object. | 278 | // idle inhibitor object. | ||
279 | QVERIFY(!idle->isInhibited()); | 279 | QVERIFY(!idle->isInhibited()); | ||
280 | QCOMPARE(inhibitedSpy.count(), 2); | 280 | QCOMPARE(inhibitedSpy.count(), 2); | ||
281 | 281 | | |||
282 | // Map the client. | 282 | // Map the client. | ||
283 | QSignalSpy windowShownSpy(c, &ShellClient::windowShown); | 283 | QSignalSpy windowShownSpy(c, &XdgShellClient::windowShown); | ||
284 | QVERIFY(windowShownSpy.isValid()); | 284 | QVERIFY(windowShownSpy.isValid()); | ||
285 | Test::render(surface.data(), QSize(100, 50), Qt::blue); | 285 | Test::render(surface.data(), QSize(100, 50), Qt::blue); | ||
286 | QVERIFY(windowShownSpy.wait()); | 286 | QVERIFY(windowShownSpy.wait()); | ||
287 | 287 | | |||
288 | // The test client became visible again, so the compositor has to honor the idle | 288 | // The test client became visible again, so the compositor has to honor the idle | ||
289 | // inhibitor object back again. | 289 | // inhibitor object back again. | ||
290 | QVERIFY(idle->isInhibited()); | 290 | QVERIFY(idle->isInhibited()); | ||
291 | QCOMPARE(inhibitedSpy.count(), 3); | 291 | QCOMPARE(inhibitedSpy.count(), 3); | ||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |