Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/virtual_desktop_test.cpp
Show All 34 Lines | |||||
35 | class VirtualDesktopTest : public QObject | 35 | class VirtualDesktopTest : public QObject | ||
36 | { | 36 | { | ||
37 | Q_OBJECT | 37 | Q_OBJECT | ||
38 | private Q_SLOTS: | 38 | private Q_SLOTS: | ||
39 | void initTestCase(); | 39 | void initTestCase(); | ||
40 | void init(); | 40 | void init(); | ||
41 | void cleanup(); | 41 | void cleanup(); | ||
42 | 42 | | |||
43 | void testNetCurrentDesktop(); | ||||
43 | void testLastDesktopRemoved_data(); | 44 | void testLastDesktopRemoved_data(); | ||
44 | void testLastDesktopRemoved(); | 45 | void testLastDesktopRemoved(); | ||
45 | }; | 46 | }; | ||
46 | 47 | | |||
47 | void VirtualDesktopTest::initTestCase() | 48 | void VirtualDesktopTest::initTestCase() | ||
48 | { | 49 | { | ||
49 | qRegisterMetaType<KWin::ShellClient*>(); | 50 | qRegisterMetaType<KWin::ShellClient*>(); | ||
50 | qRegisterMetaType<KWin::AbstractClient*>(); | 51 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
51 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | 52 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||
52 | QVERIFY(workspaceCreatedSpy.isValid()); | 53 | QVERIFY(workspaceCreatedSpy.isValid()); | ||
53 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | 54 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | ||
54 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | 55 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | ||
55 | 56 | | |||
56 | kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig)); | 57 | kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig)); | ||
57 | qputenv("KWIN_XKB_DEFAULT_KEYMAP", "1"); | 58 | qputenv("KWIN_XKB_DEFAULT_KEYMAP", "1"); | ||
58 | qputenv("XKB_DEFAULT_RULES", "evdev"); | 59 | qputenv("XKB_DEFAULT_RULES", "evdev"); | ||
59 | 60 | | |||
60 | kwinApp()->start(); | 61 | kwinApp()->start(); | ||
61 | QVERIFY(workspaceCreatedSpy.wait()); | 62 | QVERIFY(workspaceCreatedSpy.wait()); | ||
62 | waylandServer()->initWorkspace(); | 63 | waylandServer()->initWorkspace(); | ||
64 | | ||||
65 | if (kwinApp()->x11Connection()) { | ||||
66 | // verify the current desktop x11 property on startup, see BUG: 391034 | ||||
67 | Xcb::Atom currentDesktopAtom("_NET_CURRENT_DESKTOP"); | ||||
68 | QVERIFY(currentDesktopAtom.isValid()); | ||||
69 | Xcb::Property currentDesktop(0, kwinApp()->x11RootWindow(), currentDesktopAtom, XCB_ATOM_CARDINAL, 0, 1); | ||||
70 | bool ok = true; | ||||
71 | QCOMPARE(currentDesktop.value(0, &ok), 0); | ||||
72 | QVERIFY(ok); | ||||
73 | } | ||||
63 | } | 74 | } | ||
64 | 75 | | |||
65 | void VirtualDesktopTest::init() | 76 | void VirtualDesktopTest::init() | ||
66 | { | 77 | { | ||
67 | QVERIFY(Test::setupWaylandConnection()); | 78 | QVERIFY(Test::setupWaylandConnection()); | ||
68 | screens()->setCurrent(0); | 79 | screens()->setCurrent(0); | ||
69 | VirtualDesktopManager::self()->setCount(1); | 80 | VirtualDesktopManager::self()->setCount(1); | ||
70 | } | 81 | } | ||
71 | 82 | | |||
72 | void VirtualDesktopTest::cleanup() | 83 | void VirtualDesktopTest::cleanup() | ||
73 | { | 84 | { | ||
74 | Test::destroyWaylandConnection(); | 85 | Test::destroyWaylandConnection(); | ||
75 | } | 86 | } | ||
76 | 87 | | |||
88 | void VirtualDesktopTest::testNetCurrentDesktop() | ||||
89 | { | ||||
90 | if (!kwinApp()->x11Connection()) { | ||||
91 | QSKIP("Skipped on Wayland only"); | ||||
92 | } | ||||
93 | QCOMPARE(VirtualDesktopManager::self()->count(), 1u); | ||||
94 | VirtualDesktopManager::self()->setCount(4); | ||||
95 | QCOMPARE(VirtualDesktopManager::self()->count(), 4u); | ||||
96 | | ||||
97 | Xcb::Atom currentDesktopAtom("_NET_CURRENT_DESKTOP"); | ||||
98 | QVERIFY(currentDesktopAtom.isValid()); | ||||
99 | Xcb::Property currentDesktop(0, kwinApp()->x11RootWindow(), currentDesktopAtom, XCB_ATOM_CARDINAL, 0, 1); | ||||
100 | bool ok = true; | ||||
101 | QCOMPARE(currentDesktop.value(0, &ok), 0); | ||||
102 | QVERIFY(ok); | ||||
103 | | ||||
104 | // go to desktop 2 | ||||
105 | VirtualDesktopManager::self()->setCurrent(2); | ||||
106 | currentDesktop = Xcb::Property(0, kwinApp()->x11RootWindow(), currentDesktopAtom, XCB_ATOM_CARDINAL, 0, 1); | ||||
107 | QCOMPARE(currentDesktop.value(0, &ok), 1); | ||||
108 | QVERIFY(ok); | ||||
109 | | ||||
110 | // go to desktop 3 | ||||
111 | VirtualDesktopManager::self()->setCurrent(3); | ||||
112 | currentDesktop = Xcb::Property(0, kwinApp()->x11RootWindow(), currentDesktopAtom, XCB_ATOM_CARDINAL, 0, 1); | ||||
113 | QCOMPARE(currentDesktop.value(0, &ok), 2); | ||||
114 | QVERIFY(ok); | ||||
115 | | ||||
116 | // go to desktop 4 | ||||
117 | VirtualDesktopManager::self()->setCurrent(4); | ||||
118 | currentDesktop = Xcb::Property(0, kwinApp()->x11RootWindow(), currentDesktopAtom, XCB_ATOM_CARDINAL, 0, 1); | ||||
119 | QCOMPARE(currentDesktop.value(0, &ok), 3); | ||||
120 | QVERIFY(ok); | ||||
121 | | ||||
122 | // and back to first | ||||
123 | VirtualDesktopManager::self()->setCurrent(1); | ||||
124 | currentDesktop = Xcb::Property(0, kwinApp()->x11RootWindow(), currentDesktopAtom, XCB_ATOM_CARDINAL, 0, 1); | ||||
125 | QCOMPARE(currentDesktop.value(0, &ok), 0); | ||||
126 | QVERIFY(ok); | ||||
127 | } | ||||
128 | | ||||
77 | void VirtualDesktopTest::testLastDesktopRemoved_data() | 129 | void VirtualDesktopTest::testLastDesktopRemoved_data() | ||
78 | { | 130 | { | ||
79 | QTest::addColumn<Test::ShellSurfaceType>("type"); | 131 | QTest::addColumn<Test::ShellSurfaceType>("type"); | ||
80 | 132 | | |||
81 | QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell; | 133 | QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell; | ||
82 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | 134 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | ||
83 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | 135 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | ||
84 | } | 136 | } | ||
Show All 33 Lines |