Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/shell_client_test.cpp
Show First 20 Lines • Show All 97 Lines • ▼ Show 20 Line(s) | 60 | private Q_SLOTS: | |||
---|---|---|---|---|---|
98 | void testNoDecorationModeRequested_data(); | 98 | void testNoDecorationModeRequested_data(); | ||
99 | void testNoDecorationModeRequested(); | 99 | void testNoDecorationModeRequested(); | ||
100 | void testSendClientWithTransientToDesktop_data(); | 100 | void testSendClientWithTransientToDesktop_data(); | ||
101 | void testSendClientWithTransientToDesktop(); | 101 | void testSendClientWithTransientToDesktop(); | ||
102 | void testMinimizeWindowWithTransients_data(); | 102 | void testMinimizeWindowWithTransients_data(); | ||
103 | void testMinimizeWindowWithTransients(); | 103 | void testMinimizeWindowWithTransients(); | ||
104 | void testXdgDecoration_data(); | 104 | void testXdgDecoration_data(); | ||
105 | void testXdgDecoration(); | 105 | void testXdgDecoration(); | ||
106 | void testXdgNeverCommitted(); | ||||
107 | void testXdgInitialState(); | ||||
108 | void testXdgInitiallyMaximised(); | ||||
109 | void testXdgInitiallyMinimized(); | ||||
106 | }; | 110 | }; | ||
107 | 111 | | |||
108 | void TestShellClient::initTestCase() | 112 | void TestShellClient::initTestCase() | ||
109 | { | 113 | { | ||
110 | qRegisterMetaType<KWin::Deleted*>(); | 114 | qRegisterMetaType<KWin::Deleted*>(); | ||
111 | qRegisterMetaType<KWin::ShellClient*>(); | 115 | qRegisterMetaType<KWin::ShellClient*>(); | ||
112 | qRegisterMetaType<KWin::AbstractClient*>(); | 116 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
113 | qRegisterMetaType<KWayland::Client::Output*>(); | 117 | qRegisterMetaType<KWayland::Client::Output*>(); | ||
▲ Show 20 Lines • Show All 421 Lines • ▼ Show 20 Line(s) | 534 | { | |||
535 | QTest::newRow("xdgShellWmBase") << Test::ShellSurfaceType::XdgShellStable; | 539 | QTest::newRow("xdgShellWmBase") << Test::ShellSurfaceType::XdgShellStable; | ||
536 | } | 540 | } | ||
537 | 541 | | |||
538 | void TestShellClient::testFullscreenRestore() | 542 | void TestShellClient::testFullscreenRestore() | ||
539 | { | 543 | { | ||
540 | // this test verifies that windows created fullscreen can be later properly restored | 544 | // this test verifies that windows created fullscreen can be later properly restored | ||
541 | QScopedPointer<Surface> surface(Test::createSurface()); | 545 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
542 | QFETCH(Test::ShellSurfaceType, type); | 546 | QFETCH(Test::ShellSurfaceType, type); | ||
543 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | 547 | XdgShellSurface *xdgShellSurface = Test::createXdgShellSurface(type, surface.data(), surface.data(), Test::CreationSetup::CreateOnly); | ||
548 | QSignalSpy configureRequestedSpy(xdgShellSurface, SIGNAL(configureRequested(QSize, KWayland::Client::XdgShellSurface::States, quint32))); | ||||
544 | 549 | | |||
545 | XdgShellSurface *xdgShellSurface = nullptr; | | |||
546 | // fullscreen the window | 550 | // fullscreen the window | ||
547 | xdgShellSurface = qobject_cast<XdgShellSurface*>(shellSurface.data()); | | |||
548 | xdgShellSurface->setFullscreen(true); | 551 | xdgShellSurface->setFullscreen(true); | ||
552 | surface->commit(Surface::CommitFlag::None); | ||||
553 | | ||||
554 | configureRequestedSpy.wait(); | ||||
555 | QCOMPARE(configureRequestedSpy.count(), 1); | ||||
556 | | ||||
557 | const auto size = configureRequestedSpy.first()[0].value<QSize>(); | ||||
558 | const auto state = configureRequestedSpy.first()[1].value<KWayland::Client::XdgShellSurface::States>(); | ||||
549 | 559 | | |||
550 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(screens()->size(0)), Qt::blue); | 560 | QCOMPARE(size, screens()->size(0)); | ||
561 | QVERIFY(state & KWayland::Client::XdgShellSurface::State::Fullscreen); | ||||
562 | xdgShellSurface->ackConfigure(configureRequestedSpy.first()[2].toUInt()); | ||||
563 | | ||||
564 | auto c = Test::renderAndWaitForShown(surface.data(), size, Qt::blue); | ||||
551 | QVERIFY(c); | 565 | QVERIFY(c); | ||
552 | QVERIFY(c->isFullScreen()); | 566 | QVERIFY(c->isFullScreen()); | ||
553 | 567 | | |||
568 | configureRequestedSpy.wait(100); | ||||
569 | | ||||
554 | QSignalSpy fullscreenChangedSpy(c, &ShellClient::fullScreenChanged); | 570 | QSignalSpy fullscreenChangedSpy(c, &ShellClient::fullScreenChanged); | ||
555 | QVERIFY(fullscreenChangedSpy.isValid()); | 571 | QVERIFY(fullscreenChangedSpy.isValid()); | ||
556 | QSignalSpy geometryChangedSpy(c, &ShellClient::geometryChanged); | 572 | QSignalSpy geometryChangedSpy(c, &ShellClient::geometryChanged); | ||
557 | QVERIFY(geometryChangedSpy.isValid()); | 573 | QVERIFY(geometryChangedSpy.isValid()); | ||
558 | QSignalSpy configureRequestedSpy(shellSurface.data(), SIGNAL(configureRequested(QSize, KWayland::Client::XdgShellSurface::States, quint32))); | | |||
559 | QVERIFY(configureRequestedSpy.isValid()); | | |||
560 | 574 | | |||
561 | // swap back to normal | 575 | // swap back to normal | ||
576 | configureRequestedSpy.clear(); | ||||
562 | xdgShellSurface->setFullscreen(false); | 577 | xdgShellSurface->setFullscreen(false); | ||
563 | 578 | | |||
564 | QVERIFY(fullscreenChangedSpy.wait()); | 579 | QVERIFY(fullscreenChangedSpy.wait()); | ||
565 | QVERIFY(configureRequestedSpy.wait()); | 580 | QVERIFY(configureRequestedSpy.wait()); | ||
566 | QCOMPARE(configureRequestedSpy.last().first().toSize(), QSize(0, 0)); | 581 | QCOMPARE(configureRequestedSpy.last().first().toSize(), QSize(0, 0)); | ||
567 | QVERIFY(!c->isFullScreen()); | 582 | QVERIFY(!c->isFullScreen()); | ||
568 | 583 | | |||
569 | for (const auto &it: configureRequestedSpy) { | 584 | for (const auto &it: configureRequestedSpy) { | ||
570 | xdgShellSurface->ackConfigure(it[2].toInt()); | 585 | xdgShellSurface->ackConfigure(it[2].toUInt()); | ||
571 | } | 586 | } | ||
572 | 587 | | |||
573 | Test::render(surface.data(), QSize(100, 50), Qt::red); | 588 | Test::render(surface.data(), QSize(100, 50), Qt::red); | ||
574 | QVERIFY(geometryChangedSpy.wait()); | 589 | QVERIFY(geometryChangedSpy.wait()); | ||
575 | QCOMPARE(geometryChangedSpy.count(), 1); | 590 | QCOMPARE(geometryChangedSpy.count(), 1); | ||
576 | QVERIFY(!c->isFullScreen()); | 591 | QVERIFY(!c->isFullScreen()); | ||
577 | QCOMPARE(c->geometry().size(), QSize(100, 50)); | 592 | QCOMPARE(c->geometry().size(), QSize(100, 50)); | ||
578 | } | 593 | } | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 636 | { | |||
625 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | 640 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | ||
626 | QTest::newRow("xdgWmBase") << Test::ShellSurfaceType::XdgShellStable; | 641 | QTest::newRow("xdgWmBase") << Test::ShellSurfaceType::XdgShellStable; | ||
627 | } | 642 | } | ||
628 | 643 | | |||
629 | void TestShellClient::testUserSetFullscreenXdgShell() | 644 | void TestShellClient::testUserSetFullscreenXdgShell() | ||
630 | { | 645 | { | ||
631 | QScopedPointer<Surface> surface(Test::createSurface()); | 646 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
632 | QFETCH(Test::ShellSurfaceType, type); | 647 | QFETCH(Test::ShellSurfaceType, type); | ||
633 | QScopedPointer<XdgShellSurface> shellSurface(dynamic_cast<XdgShellSurface*>(Test::createShellSurface(type, surface.data()))); | 648 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface( | ||
649 | type, surface.data(), surface.data(), Test::CreationSetup::CreateOnly)); | ||||
634 | QVERIFY(!shellSurface.isNull()); | 650 | QVERIFY(!shellSurface.isNull()); | ||
651 | | ||||
652 | // wait for the initial configure event | ||||
635 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | 653 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||
636 | QVERIFY(configureRequestedSpy.isValid()); | 654 | QVERIFY(configureRequestedSpy.isValid()); | ||
655 | surface->commit(Surface::CommitFlag::None); | ||||
656 | QVERIFY(configureRequestedSpy.wait()); | ||||
657 | QCOMPARE(configureRequestedSpy.count(), 1); | ||||
658 | | ||||
659 | shellSurface->ackConfigure(configureRequestedSpy.last().at(2).value<quint32>()); | ||||
637 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 660 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
638 | QVERIFY(c); | 661 | QVERIFY(c); | ||
639 | QVERIFY(c->isActive()); | 662 | QVERIFY(c->isActive()); | ||
640 | QVERIFY(!c->isFullScreen()); | 663 | QVERIFY(!c->isFullScreen()); | ||
641 | 664 | | |||
642 | // two, one for initial sync, second as it becomes active | 665 | // The client gets activated, which gets another configure event. Though that's not relevant to the test | ||
643 | QTRY_COMPARE(configureRequestedSpy.count(), 2); | 666 | configureRequestedSpy.wait(10); | ||
644 | 667 | | |||
645 | QSignalSpy fullscreenChangedSpy(c, &AbstractClient::fullScreenChanged); | 668 | QSignalSpy fullscreenChangedSpy(c, &AbstractClient::fullScreenChanged); | ||
646 | QVERIFY(fullscreenChangedSpy.isValid()); | 669 | QVERIFY(fullscreenChangedSpy.isValid()); | ||
647 | c->setFullScreen(true); | 670 | c->setFullScreen(true); | ||
648 | QCOMPARE(c->isFullScreen(), true); | 671 | QCOMPARE(c->isFullScreen(), true); | ||
649 | configureRequestedSpy.clear(); | 672 | configureRequestedSpy.clear(); | ||
650 | QVERIFY(configureRequestedSpy.wait()); | 673 | QVERIFY(configureRequestedSpy.wait()); | ||
651 | QCOMPARE(configureRequestedSpy.count(), 1); | 674 | QCOMPARE(configureRequestedSpy.count(), 1); | ||
▲ Show 20 Lines • Show All 697 Lines • ▼ Show 20 Line(s) | 1351 | { | |||
1349 | 1372 | | |||
1350 | shellSurface->ackConfigure(configureRequestedSpy.last()[2].toInt()); | 1373 | shellSurface->ackConfigure(configureRequestedSpy.last()[2].toInt()); | ||
1351 | 1374 | | |||
1352 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 1375 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
1353 | QCOMPARE(c->userCanSetNoBorder(), expectedMode == XdgDecoration::Mode::ServerSide); | 1376 | QCOMPARE(c->userCanSetNoBorder(), expectedMode == XdgDecoration::Mode::ServerSide); | ||
1354 | QCOMPARE(c->isDecorated(), expectedMode == XdgDecoration::Mode::ServerSide); | 1377 | QCOMPARE(c->isDecorated(), expectedMode == XdgDecoration::Mode::ServerSide); | ||
1355 | } | 1378 | } | ||
1356 | 1379 | | |||
1380 | void TestShellClient::testXdgNeverCommitted() | ||||
1381 | { | ||||
1382 | //check we don't crash if we create a shell object but delete the ShellClient before committing it | ||||
1383 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
1384 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data(), nullptr, Test::CreationSetup::CreateOnly)); | ||||
1385 | } | ||||
1386 | | ||||
1387 | void TestShellClient::testXdgInitialState() | ||||
1388 | { | ||||
1389 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
1390 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data(), nullptr, Test::CreationSetup::CreateOnly)); | ||||
1391 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||||
1392 | surface->commit(Surface::CommitFlag::None); | ||||
1393 | | ||||
1394 | configureRequestedSpy.wait(); | ||||
1395 | | ||||
1396 | QCOMPARE(configureRequestedSpy.count(), 1); | ||||
1397 | | ||||
1398 | const auto size = configureRequestedSpy.first()[0].value<QSize>(); | ||||
1399 | | ||||
1400 | QCOMPARE(size, QSize(0, 0)); //client should chose it's preferred size | ||||
1401 | | ||||
1402 | shellSurface->ackConfigure(configureRequestedSpy.first()[2].toUInt()); | ||||
1403 | | ||||
1404 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(200,100), Qt::blue); | ||||
1405 | QCOMPARE(c->size(), QSize(200, 100)); | ||||
1406 | } | ||||
1407 | | ||||
1408 | void TestShellClient::testXdgInitiallyMaximised() | ||||
1409 | { | ||||
1410 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
1411 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data(), nullptr, Test::CreationSetup::CreateOnly)); | ||||
1412 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||||
1413 | | ||||
1414 | shellSurface->setMaximized(true); | ||||
1415 | surface->commit(Surface::CommitFlag::None); | ||||
1416 | | ||||
1417 | configureRequestedSpy.wait(); | ||||
1418 | | ||||
1419 | QCOMPARE(configureRequestedSpy.count(), 1); | ||||
1420 | | ||||
1421 | const auto size = configureRequestedSpy.first()[0].value<QSize>(); | ||||
1422 | const auto state = configureRequestedSpy.first()[1].value<KWayland::Client::XdgShellSurface::States>(); | ||||
1423 | | ||||
1424 | QCOMPARE(size, QSize(1280, 1024)); | ||||
1425 | QVERIFY(state & KWayland::Client::XdgShellSurface::State::Maximized); | ||||
1426 | | ||||
1427 | shellSurface->ackConfigure(configureRequestedSpy.first()[2].toUInt()); | ||||
1428 | | ||||
1429 | auto c = Test::renderAndWaitForShown(surface.data(), size, Qt::blue); | ||||
1430 | QCOMPARE(c->maximizeMode(), MaximizeFull); | ||||
1431 | QCOMPARE(c->size(), QSize(1280, 1024)); | ||||
1432 | } | ||||
1433 | | ||||
1434 | void TestShellClient::testXdgInitiallyMinimized() | ||||
1435 | { | ||||
1436 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
1437 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data(), nullptr, Test::CreationSetup::CreateOnly)); | ||||
1438 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||||
1439 | | ||||
1440 | shellSurface->requestMinimize(); | ||||
1441 | surface->commit(Surface::CommitFlag::None); | ||||
1442 | | ||||
1443 | configureRequestedSpy.wait(); | ||||
1444 | | ||||
1445 | QCOMPARE(configureRequestedSpy.count(), 1); | ||||
1446 | | ||||
1447 | const auto size = configureRequestedSpy.first()[0].value<QSize>(); | ||||
1448 | const auto state = configureRequestedSpy.first()[1].value<KWayland::Client::XdgShellSurface::States>(); | ||||
1449 | | ||||
1450 | QCOMPARE(size, QSize(0, 0)); | ||||
1451 | QCOMPARE(state, 0); | ||||
1452 | | ||||
1453 | shellSurface->ackConfigure(configureRequestedSpy.first()[2].toUInt()); | ||||
1454 | | ||||
1455 | QEXPECT_FAIL("", "Client created in a minimised state is not exposed to kwin bug 404838", Abort); | ||||
1456 | auto c = Test::renderAndWaitForShown(surface.data(), size, Qt::blue, QImage::Format_ARGB32, 10); | ||||
1457 | QVERIFY(c); | ||||
1458 | QVERIFY(c->isMinimized()); | ||||
1459 | } | ||||
1460 | | ||||
1461 | | ||||
1357 | WAYLANDTEST_MAIN(TestShellClient) | 1462 | WAYLANDTEST_MAIN(TestShellClient) | ||
1358 | #include "shell_client_test.moc" | 1463 | #include "shell_client_test.moc" |