Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/internal_window.cpp
Show All 14 Lines | |||||
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 "cursor.h" | 22 | #include "cursor.h" | ||
23 | #include "effects.h" | ||||
23 | #include "shell_client.h" | 24 | #include "shell_client.h" | ||
24 | #include "screens.h" | 25 | #include "screens.h" | ||
25 | #include "wayland_server.h" | 26 | #include "wayland_server.h" | ||
26 | #include "workspace.h" | 27 | #include "workspace.h" | ||
27 | 28 | | |||
28 | #include <QPainter> | 29 | #include <QPainter> | ||
29 | #include <QRasterWindow> | 30 | #include <QRasterWindow> | ||
30 | 31 | | |||
31 | #include <KWayland/Client/keyboard.h> | 32 | #include <KWayland/Client/keyboard.h> | ||
32 | #include <KWayland/Client/surface.h> | 33 | #include <KWayland/Client/surface.h> | ||
33 | #include <KWayland/Client/seat.h> | 34 | #include <KWayland/Client/seat.h> | ||
34 | #include <KWayland/Client/shell.h> | 35 | #include <KWayland/Client/shell.h> | ||
36 | #include <KWindowSystem> | ||||
35 | 37 | | |||
36 | #include <KWayland/Server/surface_interface.h> | 38 | #include <KWayland/Server/surface_interface.h> | ||
37 | 39 | | |||
38 | #include <linux/input.h> | 40 | #include <linux/input.h> | ||
39 | 41 | | |||
40 | using namespace KWayland::Client; | 42 | using namespace KWayland::Client; | ||
41 | 43 | | |||
44 | Q_DECLARE_METATYPE(NET::WindowType); | ||||
45 | | ||||
42 | namespace KWin | 46 | namespace KWin | ||
43 | { | 47 | { | ||
44 | 48 | | |||
45 | static const QString s_socketName = QStringLiteral("wayland_test_kwin_internal_window-0"); | 49 | static const QString s_socketName = QStringLiteral("wayland_test_kwin_internal_window-0"); | ||
46 | 50 | | |||
47 | class InternalWindowTest : public QObject | 51 | class InternalWindowTest : public QObject | ||
48 | { | 52 | { | ||
49 | Q_OBJECT | 53 | Q_OBJECT | ||
Show All 12 Lines | 54 | private Q_SLOTS: | |||
62 | void testOpacity(); | 66 | void testOpacity(); | ||
63 | void testMove(); | 67 | void testMove(); | ||
64 | void testSkipCloseAnimation_data(); | 68 | void testSkipCloseAnimation_data(); | ||
65 | void testSkipCloseAnimation(); | 69 | void testSkipCloseAnimation(); | ||
66 | void testModifierClickUnrestrictedMove(); | 70 | void testModifierClickUnrestrictedMove(); | ||
67 | void testModifierScroll(); | 71 | void testModifierScroll(); | ||
68 | void testPopup(); | 72 | void testPopup(); | ||
69 | void testScale(); | 73 | void testScale(); | ||
74 | void testWindowType_data(); | ||||
75 | void testWindowType(); | ||||
76 | void testChangeWindowType_data(); | ||||
77 | void testChangeWindowType(); | ||||
78 | void testEffectWindow(); | ||||
70 | }; | 79 | }; | ||
71 | 80 | | |||
72 | class HelperWindow : public QRasterWindow | 81 | class HelperWindow : public QRasterWindow | ||
73 | { | 82 | { | ||
74 | Q_OBJECT | 83 | Q_OBJECT | ||
75 | public: | 84 | public: | ||
76 | HelperWindow(); | 85 | HelperWindow(); | ||
77 | ~HelperWindow(); | 86 | ~HelperWindow(); | ||
▲ Show 20 Lines • Show All 629 Lines • ▼ Show 20 Line(s) | 703 | { | |||
707 | QVERIFY(clientAddedSpy.wait()); | 716 | QVERIFY(clientAddedSpy.wait()); | ||
708 | QCOMPARE(clientAddedSpy.count(), 1); | 717 | QCOMPARE(clientAddedSpy.count(), 1); | ||
709 | auto internalClient = clientAddedSpy.first().first().value<ShellClient*>(); | 718 | auto internalClient = clientAddedSpy.first().first().value<ShellClient*>(); | ||
710 | QCOMPARE(internalClient->surface()->scale(), 2); | 719 | QCOMPARE(internalClient->surface()->scale(), 2); | ||
711 | 720 | | |||
712 | QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); | 721 | QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); | ||
713 | } | 722 | } | ||
714 | 723 | | |||
724 | void InternalWindowTest::testWindowType_data() | ||||
725 | { | ||||
726 | QTest::addColumn<NET::WindowType>("windowType"); | ||||
727 | | ||||
728 | QTest::newRow("normal") << NET::Normal; | ||||
729 | QTest::newRow("desktop") << NET::Desktop; | ||||
730 | QTest::newRow("Dock") << NET::Dock; | ||||
731 | QTest::newRow("Toolbar") << NET::Toolbar; | ||||
732 | QTest::newRow("Menu") << NET::Menu; | ||||
733 | QTest::newRow("Dialog") << NET::Dialog; | ||||
734 | QTest::newRow("Utility") << NET::Utility; | ||||
735 | QTest::newRow("Splash") << NET::Splash; | ||||
736 | QTest::newRow("DropdownMenu") << NET::DropdownMenu; | ||||
737 | QTest::newRow("PopupMenu") << NET::PopupMenu; | ||||
738 | QTest::newRow("Tooltip") << NET::Tooltip; | ||||
739 | QTest::newRow("Notification") << NET::Notification; | ||||
740 | QTest::newRow("ComboBox") << NET::ComboBox; | ||||
741 | QTest::newRow("OnScreenDisplay") << NET::OnScreenDisplay; | ||||
742 | } | ||||
743 | | ||||
744 | void InternalWindowTest::testWindowType() | ||||
745 | { | ||||
746 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||||
747 | QVERIFY(clientAddedSpy.isValid()); | ||||
748 | HelperWindow win; | ||||
749 | win.setGeometry(0, 0, 100, 100); | ||||
750 | QFETCH(NET::WindowType, windowType); | ||||
751 | KWindowSystem::setType(win.winId(), windowType); | ||||
752 | win.show(); | ||||
753 | QVERIFY(clientAddedSpy.wait()); | ||||
754 | QTRY_COMPARE(clientAddedSpy.count(), 1); | ||||
755 | auto internalClient = clientAddedSpy.first().first().value<ShellClient*>(); | ||||
756 | QVERIFY(internalClient); | ||||
757 | QCOMPARE(internalClient->windowType(), windowType); | ||||
758 | } | ||||
759 | | ||||
760 | void InternalWindowTest::testChangeWindowType_data() | ||||
761 | { | ||||
762 | QTest::addColumn<NET::WindowType>("windowType"); | ||||
763 | | ||||
764 | QTest::newRow("desktop") << NET::Desktop; | ||||
765 | QTest::newRow("Dock") << NET::Dock; | ||||
766 | QTest::newRow("Toolbar") << NET::Toolbar; | ||||
767 | QTest::newRow("Menu") << NET::Menu; | ||||
768 | QTest::newRow("Dialog") << NET::Dialog; | ||||
769 | QTest::newRow("Utility") << NET::Utility; | ||||
770 | QTest::newRow("Splash") << NET::Splash; | ||||
771 | QTest::newRow("DropdownMenu") << NET::DropdownMenu; | ||||
772 | QTest::newRow("PopupMenu") << NET::PopupMenu; | ||||
773 | QTest::newRow("Tooltip") << NET::Tooltip; | ||||
774 | QTest::newRow("Notification") << NET::Notification; | ||||
775 | QTest::newRow("ComboBox") << NET::ComboBox; | ||||
776 | QTest::newRow("OnScreenDisplay") << NET::OnScreenDisplay; | ||||
777 | } | ||||
778 | | ||||
779 | void InternalWindowTest::testChangeWindowType() | ||||
780 | { | ||||
781 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||||
782 | QVERIFY(clientAddedSpy.isValid()); | ||||
783 | HelperWindow win; | ||||
784 | win.setGeometry(0, 0, 100, 100); | ||||
785 | win.show(); | ||||
786 | QVERIFY(clientAddedSpy.wait()); | ||||
787 | QTRY_COMPARE(clientAddedSpy.count(), 1); | ||||
788 | auto internalClient = clientAddedSpy.first().first().value<ShellClient*>(); | ||||
789 | QVERIFY(internalClient); | ||||
790 | QCOMPARE(internalClient->windowType(), NET::Normal); | ||||
791 | | ||||
792 | QFETCH(NET::WindowType, windowType); | ||||
793 | KWindowSystem::setType(win.winId(), windowType); | ||||
794 | QTRY_COMPARE(internalClient->windowType(), windowType); | ||||
795 | | ||||
796 | KWindowSystem::setType(win.winId(), NET::Normal); | ||||
797 | QTRY_COMPARE(internalClient->windowType(), NET::Normal); | ||||
798 | } | ||||
799 | | ||||
800 | void InternalWindowTest::testEffectWindow() | ||||
801 | { | ||||
802 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||||
803 | QVERIFY(clientAddedSpy.isValid()); | ||||
804 | HelperWindow win; | ||||
805 | win.setGeometry(0, 0, 100, 100); | ||||
806 | win.show(); | ||||
807 | QVERIFY(clientAddedSpy.wait()); | ||||
808 | auto internalClient = clientAddedSpy.first().first().value<ShellClient*>(); | ||||
809 | QVERIFY(internalClient); | ||||
810 | QVERIFY(internalClient->effectWindow()); | ||||
811 | QCOMPARE(internalClient->effectWindow()->internalWindow(), &win); | ||||
812 | | ||||
813 | QCOMPARE(effects->findWindow(&win), internalClient->effectWindow()); | ||||
814 | QCOMPARE(effects->findWindow(&win)->internalWindow(), &win); | ||||
815 | } | ||||
715 | 816 | | |||
716 | } | 817 | } | ||
717 | 818 | | |||
718 | WAYLANDTEST_MAIN(KWin::InternalWindowTest) | 819 | WAYLANDTEST_MAIN(KWin::InternalWindowTest) | ||
719 | #include "internal_window.moc" | 820 | #include "internal_window.moc" |