Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/idle_inhibition_test.cpp
Show All 12 Lines | |||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
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 "abstract_client.h" | ||||
21 | #include "platform.h" | 22 | #include "platform.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::XdgShellClient *>(); | | |||
58 | qRegisterMetaType<KWin::AbstractClient*>(); | 57 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
59 | 58 | | |||
60 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | 59 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||
61 | QVERIFY(workspaceCreatedSpy.isValid()); | 60 | QVERIFY(workspaceCreatedSpy.isValid()); | ||
62 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | 61 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | ||
63 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | 62 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | ||
64 | QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); | 63 | QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); | ||
65 | 64 | | |||
▲ Show 20 Lines • Show All 197 Lines • ▼ Show 20 Line(s) | 240 | { | |||
263 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 262 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
264 | QVERIFY(c); | 263 | QVERIFY(c); | ||
265 | 264 | | |||
266 | // This should inhibit our server object. | 265 | // This should inhibit our server object. | ||
267 | QVERIFY(idle->isInhibited()); | 266 | QVERIFY(idle->isInhibited()); | ||
268 | QCOMPARE(inhibitedSpy.count(), 1); | 267 | QCOMPARE(inhibitedSpy.count(), 1); | ||
269 | 268 | | |||
270 | // Unmap the client. | 269 | // Unmap the client. | ||
271 | QSignalSpy hiddenSpy(c, &XdgShellClient::windowHidden); | 270 | QSignalSpy hiddenSpy(c, &AbstractClient::windowHidden); | ||
272 | QVERIFY(hiddenSpy.isValid()); | 271 | QVERIFY(hiddenSpy.isValid()); | ||
273 | surface->attachBuffer(Buffer::Ptr()); | 272 | surface->attachBuffer(Buffer::Ptr()); | ||
274 | surface->commit(Surface::CommitFlag::None); | 273 | surface->commit(Surface::CommitFlag::None); | ||
275 | QVERIFY(hiddenSpy.wait()); | 274 | QVERIFY(hiddenSpy.wait()); | ||
276 | 275 | | |||
277 | // The surface is no longer visible, so the compositor don't have to honor the | 276 | // The surface is no longer visible, so the compositor don't have to honor the | ||
278 | // idle inhibitor object. | 277 | // idle inhibitor object. | ||
279 | QVERIFY(!idle->isInhibited()); | 278 | QVERIFY(!idle->isInhibited()); | ||
280 | QCOMPARE(inhibitedSpy.count(), 2); | 279 | QCOMPARE(inhibitedSpy.count(), 2); | ||
281 | 280 | | |||
282 | // Map the client. | 281 | // Map the client. | ||
283 | QSignalSpy windowShownSpy(c, &XdgShellClient::windowShown); | 282 | QSignalSpy windowShownSpy(c, &AbstractClient::windowShown); | ||
284 | QVERIFY(windowShownSpy.isValid()); | 283 | QVERIFY(windowShownSpy.isValid()); | ||
285 | Test::render(surface.data(), QSize(100, 50), Qt::blue); | 284 | Test::render(surface.data(), QSize(100, 50), Qt::blue); | ||
286 | QVERIFY(windowShownSpy.wait()); | 285 | QVERIFY(windowShownSpy.wait()); | ||
287 | 286 | | |||
288 | // The test client became visible again, so the compositor has to honor the idle | 287 | // The test client became visible again, so the compositor has to honor the idle | ||
289 | // inhibitor object back again. | 288 | // inhibitor object back again. | ||
290 | QVERIFY(idle->isInhibited()); | 289 | QVERIFY(idle->isInhibited()); | ||
291 | QCOMPARE(inhibitedSpy.count(), 3); | 290 | QCOMPARE(inhibitedSpy.count(), 3); | ||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |