Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/shell_client_test.cpp
Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Line(s) | 60 | private Q_SLOTS: | |||
---|---|---|---|---|---|
96 | void testNoDecorationModeRequested_data(); | 96 | void testNoDecorationModeRequested_data(); | ||
97 | void testNoDecorationModeRequested(); | 97 | void testNoDecorationModeRequested(); | ||
98 | void testSendClientWithTransientToDesktop_data(); | 98 | void testSendClientWithTransientToDesktop_data(); | ||
99 | void testSendClientWithTransientToDesktop(); | 99 | void testSendClientWithTransientToDesktop(); | ||
100 | void testMinimizeWindowWithTransients_data(); | 100 | void testMinimizeWindowWithTransients_data(); | ||
101 | void testMinimizeWindowWithTransients(); | 101 | void testMinimizeWindowWithTransients(); | ||
102 | void testXdgDecoration_data(); | 102 | void testXdgDecoration_data(); | ||
103 | void testXdgDecoration(); | 103 | void testXdgDecoration(); | ||
104 | void testXdgNeverCommitted(); | ||||
105 | void testXdgInitialState(); | ||||
106 | void testXdgInitiallyMaximised(); | ||||
107 | void testXdgInitiallyFullscreen(); | ||||
104 | }; | 108 | }; | ||
105 | 109 | | |||
106 | void TestShellClient::initTestCase() | 110 | void TestShellClient::initTestCase() | ||
107 | { | 111 | { | ||
108 | qRegisterMetaType<KWin::Deleted*>(); | 112 | qRegisterMetaType<KWin::Deleted*>(); | ||
109 | qRegisterMetaType<KWin::ShellClient*>(); | 113 | qRegisterMetaType<KWin::ShellClient*>(); | ||
110 | qRegisterMetaType<KWin::AbstractClient*>(); | 114 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
111 | qRegisterMetaType<KWayland::Client::Output*>(); | 115 | qRegisterMetaType<KWayland::Client::Output*>(); | ||
▲ Show 20 Lines • Show All 460 Lines • ▼ Show 20 Line(s) | 572 | { | |||
572 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | 576 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | ||
573 | QTest::newRow("xdgWmBase") << Test::ShellSurfaceType::XdgShellStable; | 577 | QTest::newRow("xdgWmBase") << Test::ShellSurfaceType::XdgShellStable; | ||
574 | } | 578 | } | ||
575 | 579 | | |||
576 | void TestShellClient::testUserSetFullscreenXdgShell() | 580 | void TestShellClient::testUserSetFullscreenXdgShell() | ||
577 | { | 581 | { | ||
578 | QScopedPointer<Surface> surface(Test::createSurface()); | 582 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
579 | QFETCH(Test::ShellSurfaceType, type); | 583 | QFETCH(Test::ShellSurfaceType, type); | ||
580 | QScopedPointer<XdgShellSurface> shellSurface(dynamic_cast<XdgShellSurface*>(Test::createShellSurface(type, surface.data()))); | 584 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface( | ||
585 | type, surface.data(), surface.data(), Test::CreationSetup::CreateOnly)); | ||||
581 | QVERIFY(!shellSurface.isNull()); | 586 | QVERIFY(!shellSurface.isNull()); | ||
587 | | ||||
588 | // wait for the initial configure event | ||||
582 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | 589 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||
583 | QVERIFY(configureRequestedSpy.isValid()); | 590 | QVERIFY(configureRequestedSpy.isValid()); | ||
591 | surface->commit(Surface::CommitFlag::None); | ||||
592 | QVERIFY(configureRequestedSpy.wait()); | ||||
593 | QCOMPARE(configureRequestedSpy.count(), 1); | ||||
594 | | ||||
595 | shellSurface->ackConfigure(configureRequestedSpy.last().at(2).value<quint32>()); | ||||
584 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 596 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
585 | QVERIFY(c); | 597 | QVERIFY(c); | ||
586 | QVERIFY(c->isActive()); | 598 | QVERIFY(c->isActive()); | ||
587 | QVERIFY(!c->isFullScreen()); | 599 | QVERIFY(!c->isFullScreen()); | ||
588 | 600 | | |||
589 | // two, one for initial sync, second as it becomes active | 601 | QTRY_COMPARE(configureRequestedSpy.count(), 1); | ||
590 | QTRY_COMPARE(configureRequestedSpy.count(), 2); | | |||
591 | 602 | | |||
592 | QSignalSpy fullscreenChangedSpy(c, &AbstractClient::fullScreenChanged); | 603 | QSignalSpy fullscreenChangedSpy(c, &AbstractClient::fullScreenChanged); | ||
593 | QVERIFY(fullscreenChangedSpy.isValid()); | 604 | QVERIFY(fullscreenChangedSpy.isValid()); | ||
594 | c->setFullScreen(true); | 605 | c->setFullScreen(true); | ||
595 | QCOMPARE(c->isFullScreen(), true); | 606 | QCOMPARE(c->isFullScreen(), true); | ||
596 | configureRequestedSpy.clear(); | 607 | configureRequestedSpy.clear(); | ||
597 | QVERIFY(configureRequestedSpy.wait()); | 608 | QVERIFY(configureRequestedSpy.wait()); | ||
598 | QCOMPARE(configureRequestedSpy.count(), 1); | 609 | QCOMPARE(configureRequestedSpy.count(), 1); | ||
▲ Show 20 Lines • Show All 697 Lines • ▼ Show 20 Line(s) | 1286 | { | |||
1296 | 1307 | | |||
1297 | shellSurface->ackConfigure(configureRequestedSpy.last()[2].toInt()); | 1308 | shellSurface->ackConfigure(configureRequestedSpy.last()[2].toInt()); | ||
1298 | 1309 | | |||
1299 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 1310 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
1300 | QCOMPARE(c->userCanSetNoBorder(), expectedMode == XdgDecoration::Mode::ServerSide); | 1311 | QCOMPARE(c->userCanSetNoBorder(), expectedMode == XdgDecoration::Mode::ServerSide); | ||
1301 | QCOMPARE(c->isDecorated(), expectedMode == XdgDecoration::Mode::ServerSide); | 1312 | QCOMPARE(c->isDecorated(), expectedMode == XdgDecoration::Mode::ServerSide); | ||
1302 | } | 1313 | } | ||
1303 | 1314 | | |||
1315 | void TestShellClient::testXdgNeverCommitted() | ||||
1316 | { | ||||
1317 | //check we don't crash if we create a shell object but delete the ShellClient before committing it | ||||
1318 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
1319 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data(), nullptr, Test::CreationSetup::CreateOnly)); | ||||
1320 | } | ||||
1321 | | ||||
1322 | void TestShellClient::testXdgInitialState() | ||||
1323 | { | ||||
1324 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
1325 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data(), nullptr, Test::CreationSetup::CreateOnly)); | ||||
1326 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||||
1327 | surface->commit(Surface::CommitFlag::None); | ||||
1328 | | ||||
1329 | configureRequestedSpy.wait(); | ||||
1330 | | ||||
1331 | QCOMPARE(configureRequestedSpy.count(), 1); | ||||
1332 | | ||||
1333 | const auto size = configureRequestedSpy.first()[0].value<QSize>(); | ||||
1334 | | ||||
1335 | QCOMPARE(size, QSize(0, 0)); //client should chose it's preferred size | ||||
1336 | | ||||
1337 | shellSurface->ackConfigure(configureRequestedSpy.first()[2].toUInt()); | ||||
1338 | | ||||
1339 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(200,100), Qt::blue); | ||||
1340 | QCOMPARE(c->size(), QSize(200, 100)); | ||||
1341 | } | ||||
1342 | | ||||
1343 | void TestShellClient::testXdgInitiallyMaximised() | ||||
1344 | { | ||||
1345 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
1346 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data(), nullptr, Test::CreationSetup::CreateOnly)); | ||||
1347 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||||
1348 | | ||||
1349 | shellSurface->setMaximized(true); | ||||
1350 | surface->commit(Surface::CommitFlag::None); | ||||
1351 | | ||||
1352 | configureRequestedSpy.wait(); | ||||
1353 | | ||||
1354 | QCOMPARE(configureRequestedSpy.count(), 1); | ||||
1355 | | ||||
1356 | const auto size = configureRequestedSpy.first()[0].value<QSize>(); | ||||
1357 | const auto state = configureRequestedSpy.first()[1].value<KWayland::Client::XdgShellSurface::States>(); | ||||
1358 | | ||||
1359 | QCOMPARE(size, QSize(1280, 1024)); | ||||
1360 | QVERIFY(state & KWayland::Client::XdgShellSurface::State::Maximized); | ||||
1361 | | ||||
1362 | shellSurface->ackConfigure(configureRequestedSpy.first()[2].toUInt()); | ||||
1363 | | ||||
1364 | auto c = Test::renderAndWaitForShown(surface.data(), size, Qt::blue); | ||||
1365 | QCOMPARE(c->maximizeMode(), MaximizeFull); | ||||
1366 | QCOMPARE(c->size(), QSize(1280, 1024)); | ||||
1367 | } | ||||
1368 | | ||||
1369 | void TestShellClient::testXdgInitiallyFullscreen() | ||||
1370 | { | ||||
1371 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
1372 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data(), nullptr, Test::CreationSetup::CreateOnly)); | ||||
1373 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||||
1374 | | ||||
1375 | shellSurface->setFullscreen(true); | ||||
1376 | surface->commit(Surface::CommitFlag::None); | ||||
1377 | | ||||
1378 | configureRequestedSpy.wait(); | ||||
1379 | | ||||
1380 | QCOMPARE(configureRequestedSpy.count(), 1); | ||||
1381 | | ||||
1382 | const auto size = configureRequestedSpy.first()[0].value<QSize>(); | ||||
1383 | const auto state = configureRequestedSpy.first()[1].value<KWayland::Client::XdgShellSurface::States>(); | ||||
1384 | | ||||
1385 | QCOMPARE(size, QSize(1280, 1024)); | ||||
1386 | QVERIFY(state & KWayland::Client::XdgShellSurface::State::Fullscreen); | ||||
1387 | | ||||
1388 | shellSurface->ackConfigure(configureRequestedSpy.first()[2].toUInt()); | ||||
1389 | | ||||
1390 | auto c = Test::renderAndWaitForShown(surface.data(), size, Qt::blue); | ||||
1391 | QCOMPARE(c->isFullScreen(), true); | ||||
1392 | QCOMPARE(c->size(), QSize(1280, 1024)); | ||||
1393 | } | ||||
1394 | | ||||
1395 | | ||||
1304 | WAYLANDTEST_MAIN(TestShellClient) | 1396 | WAYLANDTEST_MAIN(TestShellClient) | ||
1305 | #include "shell_client_test.moc" | 1397 | #include "shell_client_test.moc" |