Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/shell_client_test.cpp
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Line(s) | 69 | private Q_SLOTS: | |||
---|---|---|---|---|---|
114 | void testMinimizeWindowWithTransients(); | 114 | void testMinimizeWindowWithTransients(); | ||
115 | void testXdgDecoration_data(); | 115 | void testXdgDecoration_data(); | ||
116 | void testXdgDecoration(); | 116 | void testXdgDecoration(); | ||
117 | void testXdgNeverCommitted(); | 117 | void testXdgNeverCommitted(); | ||
118 | void testXdgInitialState(); | 118 | void testXdgInitialState(); | ||
119 | void testXdgInitiallyMaximised(); | 119 | void testXdgInitiallyMaximised(); | ||
120 | void testXdgInitiallyMinimized(); | 120 | void testXdgInitiallyMinimized(); | ||
121 | void testXdgWindowGeometry(); | 121 | void testXdgWindowGeometry(); | ||
122 | void testMaximizeHorizontal_data(); | ||||
123 | void testMaximizeHorizontal(); | ||||
124 | void testMaximizeVertical_data(); | ||||
125 | void testMaximizeVertical(); | ||||
126 | void testMaximizeFull_data(); | ||||
127 | void testMaximizeFull(); | ||||
122 | }; | 128 | }; | ||
123 | 129 | | |||
124 | void TestShellClient::initTestCase() | 130 | void TestShellClient::initTestCase() | ||
125 | { | 131 | { | ||
126 | qRegisterMetaType<KWin::Deleted*>(); | 132 | qRegisterMetaType<KWin::Deleted*>(); | ||
127 | qRegisterMetaType<KWin::ShellClient*>(); | 133 | qRegisterMetaType<KWin::ShellClient*>(); | ||
128 | qRegisterMetaType<KWin::AbstractClient*>(); | 134 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
129 | qRegisterMetaType<KWayland::Client::Output*>(); | 135 | qRegisterMetaType<KWayland::Client::Output*>(); | ||
▲ Show 20 Lines • Show All 1380 Lines • ▼ Show 20 Line(s) | 1489 | { | |||
1510 | 1516 | | |||
1511 | c->setFullScreen(true); | 1517 | c->setFullScreen(true); | ||
1512 | configureRequestedSpy.wait(); | 1518 | configureRequestedSpy.wait(); | ||
1513 | // when full screen, the window geometry (i.e without margins) should fill the screen | 1519 | // when full screen, the window geometry (i.e without margins) should fill the screen | ||
1514 | const QSize requestedFullScreenSize = configureRequestedSpy.last()[0].value<QSize>(); | 1520 | const QSize requestedFullScreenSize = configureRequestedSpy.last()[0].value<QSize>(); | ||
1515 | QCOMPARE(requestedFullScreenSize, QSize(1280, 1024)); | 1521 | QCOMPARE(requestedFullScreenSize, QSize(1280, 1024)); | ||
1516 | } | 1522 | } | ||
1517 | 1523 | | |||
1524 | void TestShellClient::testMaximizeHorizontal_data() | ||||
1525 | { | ||||
1526 | QTest::addColumn<Test::ShellSurfaceType>("type"); | ||||
1527 | QTest::newRow("XdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | ||||
1528 | QTest::newRow("XdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | ||||
1529 | QTest::newRow("XdgWmBase") << Test::ShellSurfaceType::XdgShellStable; | ||||
1530 | } | ||||
1531 | | ||||
1532 | void TestShellClient::testMaximizeHorizontal() | ||||
1533 | { | ||||
1534 | // Create the test client. | ||||
1535 | QFETCH(Test::ShellSurfaceType, type); | ||||
1536 | QScopedPointer<Surface> surface; | ||||
1537 | surface.reset(Test::createSurface()); | ||||
1538 | QScopedPointer<XdgShellSurface> shellSurface; | ||||
1539 | shellSurface.reset(createXdgShellSurface(type, surface.data(), surface.data(), Test::CreationSetup::CreateOnly)); | ||||
1540 | QScopedPointer<QSignalSpy> configureRequestedSpy; | ||||
1541 | configureRequestedSpy.reset(new QSignalSpy(shellSurface.data(), &XdgShellSurface::configureRequested)); | ||||
1542 | surface->commit(Surface::CommitFlag::None); | ||||
1543 | | ||||
1544 | // Wait for the initial configure event. | ||||
1545 | XdgShellSurface::States states; | ||||
1546 | QVERIFY(configureRequestedSpy->wait()); | ||||
1547 | QCOMPARE(configureRequestedSpy->count(), 1); | ||||
1548 | QCOMPARE(configureRequestedSpy->last().at(0).toSize(), QSize(0, 0)); | ||||
1549 | states = configureRequestedSpy->last().at(1).value<XdgShellSurface::States>(); | ||||
1550 | QVERIFY(!states.testFlag(XdgShellSurface::State::Activated)); | ||||
1551 | QVERIFY(!states.testFlag(XdgShellSurface::State::Maximized)); | ||||
1552 | | ||||
1553 | // Map the client. | ||||
1554 | shellSurface->ackConfigure(configureRequestedSpy->last().at(2).value<quint32>()); | ||||
1555 | ShellClient *client = Test::renderAndWaitForShown(surface.data(), QSize(800, 600), Qt::blue); | ||||
1556 | QVERIFY(client); | ||||
1557 | QVERIFY(client->isActive()); | ||||
1558 | QVERIFY(client->isMaximizable()); | ||||
1559 | QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeRestore); | ||||
1560 | QCOMPARE(client->requestedMaximizeMode(), MaximizeMode::MaximizeRestore); | ||||
1561 | QCOMPARE(client->size(), QSize(800, 600)); | ||||
1562 | | ||||
1563 | // We should receive a configure event when the client becomes active. | ||||
1564 | QVERIFY(configureRequestedSpy->wait()); | ||||
1565 | QCOMPARE(configureRequestedSpy->count(), 2); | ||||
1566 | states = configureRequestedSpy->last().at(1).value<XdgShellSurface::States>(); | ||||
1567 | QVERIFY(states.testFlag(XdgShellSurface::State::Activated)); | ||||
1568 | QVERIFY(!states.testFlag(XdgShellSurface::State::Maximized)); | ||||
1569 | | ||||
1570 | // Maximize the test client in horizontal direction. | ||||
1571 | workspace()->slotWindowMaximizeHorizontal(); | ||||
1572 | QCOMPARE(client->requestedMaximizeMode(), MaximizeHorizontal); | ||||
1573 | QCOMPARE(client->maximizeMode(), MaximizeRestore); | ||||
1574 | QVERIFY(configureRequestedSpy->wait()); | ||||
1575 | QCOMPARE(configureRequestedSpy->count(), 3); | ||||
1576 | QCOMPARE(configureRequestedSpy->last().at(0).toSize(), QSize(1280, 600)); | ||||
1577 | states = configureRequestedSpy->last().at(1).value<XdgShellSurface::States>(); | ||||
1578 | QVERIFY(!states.testFlag(XdgShellSurface::State::Maximized)); | ||||
1579 | | ||||
1580 | // Draw contents of the maximized client. | ||||
1581 | QSignalSpy geometryChangedSpy(client, &AbstractClient::geometryChanged); | ||||
1582 | QVERIFY(geometryChangedSpy.isValid()); | ||||
1583 | shellSurface->ackConfigure(configureRequestedSpy->last().at(2).value<quint32>()); | ||||
1584 | Test::render(surface.data(), QSize(1280, 600), Qt::blue); | ||||
1585 | QVERIFY(geometryChangedSpy.wait()); | ||||
1586 | QCOMPARE(client->size(), QSize(1280, 600)); | ||||
1587 | QCOMPARE(client->requestedMaximizeMode(), MaximizeHorizontal); | ||||
1588 | QCOMPARE(client->maximizeMode(), MaximizeHorizontal); | ||||
1589 | | ||||
1590 | // Restore the client. | ||||
1591 | workspace()->slotWindowMaximizeHorizontal(); | ||||
1592 | QCOMPARE(client->requestedMaximizeMode(), MaximizeRestore); | ||||
1593 | QCOMPARE(client->maximizeMode(), MaximizeHorizontal); | ||||
1594 | QVERIFY(configureRequestedSpy->wait()); | ||||
1595 | QCOMPARE(configureRequestedSpy->count(), 4); | ||||
1596 | QCOMPARE(configureRequestedSpy->last().at(0).toSize(), QSize(800, 600)); | ||||
1597 | states = configureRequestedSpy->last().at(1).value<XdgShellSurface::States>(); | ||||
1598 | QVERIFY(!states.testFlag(XdgShellSurface::State::Maximized)); | ||||
1599 | | ||||
1600 | // Draw contents of the restored client. | ||||
1601 | shellSurface->ackConfigure(configureRequestedSpy->last().at(2).value<quint32>()); | ||||
1602 | Test::render(surface.data(), QSize(800, 600), Qt::blue); | ||||
1603 | QVERIFY(geometryChangedSpy.wait()); | ||||
1604 | QCOMPARE(client->size(), QSize(800, 600)); | ||||
1605 | QCOMPARE(client->requestedMaximizeMode(), MaximizeRestore); | ||||
1606 | QCOMPARE(client->maximizeMode(), MaximizeRestore); | ||||
1607 | | ||||
1608 | // Destroy the client. | ||||
1609 | shellSurface.reset(); | ||||
1610 | surface.reset(); | ||||
1611 | QVERIFY(Test::waitForWindowDestroyed(client)); | ||||
1612 | } | ||||
1613 | | ||||
1614 | void TestShellClient::testMaximizeVertical_data() | ||||
1615 | { | ||||
1616 | QTest::addColumn<Test::ShellSurfaceType>("type"); | ||||
1617 | QTest::newRow("XdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | ||||
1618 | QTest::newRow("XdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | ||||
1619 | QTest::newRow("XdgWmBase") << Test::ShellSurfaceType::XdgShellStable; | ||||
1620 | } | ||||
1621 | | ||||
1622 | void TestShellClient::testMaximizeVertical() | ||||
1623 | { | ||||
1624 | // Create the test client. | ||||
1625 | QFETCH(Test::ShellSurfaceType, type); | ||||
1626 | QScopedPointer<Surface> surface; | ||||
1627 | surface.reset(Test::createSurface()); | ||||
1628 | QScopedPointer<XdgShellSurface> shellSurface; | ||||
1629 | shellSurface.reset(createXdgShellSurface(type, surface.data(), surface.data(), Test::CreationSetup::CreateOnly)); | ||||
1630 | QScopedPointer<QSignalSpy> configureRequestedSpy; | ||||
1631 | configureRequestedSpy.reset(new QSignalSpy(shellSurface.data(), &XdgShellSurface::configureRequested)); | ||||
1632 | surface->commit(Surface::CommitFlag::None); | ||||
1633 | | ||||
1634 | // Wait for the initial configure event. | ||||
1635 | XdgShellSurface::States states; | ||||
1636 | QVERIFY(configureRequestedSpy->wait()); | ||||
1637 | QCOMPARE(configureRequestedSpy->count(), 1); | ||||
1638 | QCOMPARE(configureRequestedSpy->last().at(0).toSize(), QSize(0, 0)); | ||||
1639 | states = configureRequestedSpy->last().at(1).value<XdgShellSurface::States>(); | ||||
1640 | QVERIFY(!states.testFlag(XdgShellSurface::State::Activated)); | ||||
1641 | QVERIFY(!states.testFlag(XdgShellSurface::State::Maximized)); | ||||
1642 | | ||||
1643 | // Map the client. | ||||
1644 | shellSurface->ackConfigure(configureRequestedSpy->last().at(2).value<quint32>()); | ||||
1645 | ShellClient *client = Test::renderAndWaitForShown(surface.data(), QSize(800, 600), Qt::blue); | ||||
1646 | QVERIFY(client); | ||||
1647 | QVERIFY(client->isActive()); | ||||
1648 | QVERIFY(client->isMaximizable()); | ||||
1649 | QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeRestore); | ||||
1650 | QCOMPARE(client->requestedMaximizeMode(), MaximizeMode::MaximizeRestore); | ||||
1651 | QCOMPARE(client->size(), QSize(800, 600)); | ||||
1652 | | ||||
1653 | // We should receive a configure event when the client becomes active. | ||||
1654 | QVERIFY(configureRequestedSpy->wait()); | ||||
1655 | QCOMPARE(configureRequestedSpy->count(), 2); | ||||
1656 | states = configureRequestedSpy->last().at(1).value<XdgShellSurface::States>(); | ||||
1657 | QVERIFY(states.testFlag(XdgShellSurface::State::Activated)); | ||||
1658 | QVERIFY(!states.testFlag(XdgShellSurface::State::Maximized)); | ||||
1659 | | ||||
1660 | // Maximize the test client in vertical direction. | ||||
1661 | workspace()->slotWindowMaximizeVertical(); | ||||
1662 | QCOMPARE(client->requestedMaximizeMode(), MaximizeVertical); | ||||
1663 | QCOMPARE(client->maximizeMode(), MaximizeRestore); | ||||
1664 | QVERIFY(configureRequestedSpy->wait()); | ||||
1665 | QCOMPARE(configureRequestedSpy->count(), 3); | ||||
1666 | QCOMPARE(configureRequestedSpy->last().at(0).toSize(), QSize(800, 1024)); | ||||
1667 | states = configureRequestedSpy->last().at(1).value<XdgShellSurface::States>(); | ||||
1668 | QVERIFY(!states.testFlag(XdgShellSurface::State::Maximized)); | ||||
1669 | | ||||
1670 | // Draw contents of the maximized client. | ||||
1671 | QSignalSpy geometryChangedSpy(client, &AbstractClient::geometryChanged); | ||||
1672 | QVERIFY(geometryChangedSpy.isValid()); | ||||
1673 | shellSurface->ackConfigure(configureRequestedSpy->last().at(2).value<quint32>()); | ||||
1674 | Test::render(surface.data(), QSize(800, 1024), Qt::blue); | ||||
1675 | QVERIFY(geometryChangedSpy.wait()); | ||||
1676 | QCOMPARE(client->size(), QSize(800, 1024)); | ||||
1677 | QCOMPARE(client->requestedMaximizeMode(), MaximizeVertical); | ||||
1678 | QCOMPARE(client->maximizeMode(), MaximizeVertical); | ||||
1679 | | ||||
1680 | // Restore the client. | ||||
1681 | workspace()->slotWindowMaximizeVertical(); | ||||
1682 | QCOMPARE(client->requestedMaximizeMode(), MaximizeRestore); | ||||
1683 | QCOMPARE(client->maximizeMode(), MaximizeVertical); | ||||
1684 | QVERIFY(configureRequestedSpy->wait()); | ||||
1685 | QCOMPARE(configureRequestedSpy->count(), 4); | ||||
1686 | QCOMPARE(configureRequestedSpy->last().at(0).toSize(), QSize(800, 600)); | ||||
1687 | states = configureRequestedSpy->last().at(1).value<XdgShellSurface::States>(); | ||||
1688 | QVERIFY(!states.testFlag(XdgShellSurface::State::Maximized)); | ||||
1689 | | ||||
1690 | // Draw contents of the restored client. | ||||
1691 | shellSurface->ackConfigure(configureRequestedSpy->last().at(2).value<quint32>()); | ||||
1692 | Test::render(surface.data(), QSize(800, 600), Qt::blue); | ||||
1693 | QVERIFY(geometryChangedSpy.wait()); | ||||
1694 | QCOMPARE(client->size(), QSize(800, 600)); | ||||
1695 | QCOMPARE(client->requestedMaximizeMode(), MaximizeRestore); | ||||
1696 | QCOMPARE(client->maximizeMode(), MaximizeRestore); | ||||
1697 | | ||||
1698 | // Destroy the client. | ||||
1699 | shellSurface.reset(); | ||||
1700 | surface.reset(); | ||||
1701 | QVERIFY(Test::waitForWindowDestroyed(client)); | ||||
1702 | } | ||||
1703 | | ||||
1704 | void TestShellClient::testMaximizeFull_data() | ||||
1705 | { | ||||
1706 | QTest::addColumn<Test::ShellSurfaceType>("type"); | ||||
1707 | QTest::newRow("XdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | ||||
1708 | QTest::newRow("XdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | ||||
1709 | QTest::newRow("XdgWmBase") << Test::ShellSurfaceType::XdgShellStable; | ||||
1710 | } | ||||
1711 | | ||||
1712 | void TestShellClient::testMaximizeFull() | ||||
1713 | { | ||||
1714 | // Create the test client. | ||||
1715 | QFETCH(Test::ShellSurfaceType, type); | ||||
1716 | QScopedPointer<Surface> surface; | ||||
1717 | surface.reset(Test::createSurface()); | ||||
1718 | QScopedPointer<XdgShellSurface> shellSurface; | ||||
1719 | shellSurface.reset(createXdgShellSurface(type, surface.data(), surface.data(), Test::CreationSetup::CreateOnly)); | ||||
1720 | QScopedPointer<QSignalSpy> configureRequestedSpy; | ||||
1721 | configureRequestedSpy.reset(new QSignalSpy(shellSurface.data(), &XdgShellSurface::configureRequested)); | ||||
1722 | surface->commit(Surface::CommitFlag::None); | ||||
1723 | | ||||
1724 | // Wait for the initial configure event. | ||||
1725 | XdgShellSurface::States states; | ||||
1726 | QVERIFY(configureRequestedSpy->wait()); | ||||
1727 | QCOMPARE(configureRequestedSpy->count(), 1); | ||||
1728 | QCOMPARE(configureRequestedSpy->last().at(0).toSize(), QSize(0, 0)); | ||||
1729 | states = configureRequestedSpy->last().at(1).value<XdgShellSurface::States>(); | ||||
1730 | QVERIFY(!states.testFlag(XdgShellSurface::State::Activated)); | ||||
1731 | QVERIFY(!states.testFlag(XdgShellSurface::State::Maximized)); | ||||
1732 | | ||||
1733 | // Map the client. | ||||
1734 | shellSurface->ackConfigure(configureRequestedSpy->last().at(2).value<quint32>()); | ||||
1735 | ShellClient *client = Test::renderAndWaitForShown(surface.data(), QSize(800, 600), Qt::blue); | ||||
1736 | QVERIFY(client); | ||||
1737 | QVERIFY(client->isActive()); | ||||
1738 | QVERIFY(client->isMaximizable()); | ||||
1739 | QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeRestore); | ||||
1740 | QCOMPARE(client->requestedMaximizeMode(), MaximizeMode::MaximizeRestore); | ||||
1741 | QCOMPARE(client->size(), QSize(800, 600)); | ||||
1742 | | ||||
1743 | // We should receive a configure event when the client becomes active. | ||||
1744 | QVERIFY(configureRequestedSpy->wait()); | ||||
1745 | QCOMPARE(configureRequestedSpy->count(), 2); | ||||
1746 | states = configureRequestedSpy->last().at(1).value<XdgShellSurface::States>(); | ||||
1747 | QVERIFY(states.testFlag(XdgShellSurface::State::Activated)); | ||||
1748 | QVERIFY(!states.testFlag(XdgShellSurface::State::Maximized)); | ||||
1749 | | ||||
1750 | // Maximize the test client. | ||||
1751 | workspace()->slotWindowMaximize(); | ||||
1752 | QCOMPARE(client->requestedMaximizeMode(), MaximizeFull); | ||||
1753 | QCOMPARE(client->maximizeMode(), MaximizeRestore); | ||||
1754 | QVERIFY(configureRequestedSpy->wait()); | ||||
1755 | QCOMPARE(configureRequestedSpy->count(), 3); | ||||
1756 | QCOMPARE(configureRequestedSpy->last().at(0).toSize(), QSize(1280, 1024)); | ||||
1757 | states = configureRequestedSpy->last().at(1).value<XdgShellSurface::States>(); | ||||
1758 | QVERIFY(states.testFlag(XdgShellSurface::State::Maximized)); | ||||
1759 | | ||||
1760 | // Draw contents of the maximized client. | ||||
1761 | QSignalSpy geometryChangedSpy(client, &AbstractClient::geometryChanged); | ||||
1762 | QVERIFY(geometryChangedSpy.isValid()); | ||||
1763 | shellSurface->ackConfigure(configureRequestedSpy->last().at(2).value<quint32>()); | ||||
1764 | Test::render(surface.data(), QSize(1280, 1024), Qt::blue); | ||||
1765 | QVERIFY(geometryChangedSpy.wait()); | ||||
1766 | QCOMPARE(client->size(), QSize(1280, 1024)); | ||||
1767 | QCOMPARE(client->requestedMaximizeMode(), MaximizeFull); | ||||
1768 | QCOMPARE(client->maximizeMode(), MaximizeFull); | ||||
1769 | | ||||
1770 | // Restore the client. | ||||
1771 | workspace()->slotWindowMaximize(); | ||||
1772 | QCOMPARE(client->requestedMaximizeMode(), MaximizeRestore); | ||||
1773 | QCOMPARE(client->maximizeMode(), MaximizeFull); | ||||
1774 | QVERIFY(configureRequestedSpy->wait()); | ||||
1775 | QCOMPARE(configureRequestedSpy->count(), 4); | ||||
1776 | QCOMPARE(configureRequestedSpy->last().at(0).toSize(), QSize(800, 600)); | ||||
1777 | states = configureRequestedSpy->last().at(1).value<XdgShellSurface::States>(); | ||||
1778 | QVERIFY(!states.testFlag(XdgShellSurface::State::Maximized)); | ||||
1779 | | ||||
1780 | // Draw contents of the restored client. | ||||
1781 | shellSurface->ackConfigure(configureRequestedSpy->last().at(2).value<quint32>()); | ||||
1782 | Test::render(surface.data(), QSize(800, 600), Qt::blue); | ||||
1783 | QVERIFY(geometryChangedSpy.wait()); | ||||
1784 | QCOMPARE(client->size(), QSize(800, 600)); | ||||
1785 | QCOMPARE(client->requestedMaximizeMode(), MaximizeRestore); | ||||
1786 | QCOMPARE(client->maximizeMode(), MaximizeRestore); | ||||
1787 | | ||||
1788 | // Destroy the client. | ||||
1789 | shellSurface.reset(); | ||||
1790 | surface.reset(); | ||||
1791 | QVERIFY(Test::waitForWindowDestroyed(client)); | ||||
1792 | } | ||||
1793 | | ||||
1518 | WAYLANDTEST_MAIN(TestShellClient) | 1794 | WAYLANDTEST_MAIN(TestShellClient) | ||
1519 | #include "shell_client_test.moc" | 1795 | #include "shell_client_test.moc" |