Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/screen_changes_test.cpp
Show All 18 Lines | |||||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "kwin_wayland_test.h" | 20 | #include "kwin_wayland_test.h" | ||
21 | #include "cursor.h" | 21 | #include "cursor.h" | ||
22 | #include "platform.h" | 22 | #include "platform.h" | ||
23 | #include "screens.h" | 23 | #include "screens.h" | ||
24 | #include "wayland_server.h" | 24 | #include "wayland_server.h" | ||
25 | 25 | | |||
26 | #include <KWayland/Client/output.h> | 26 | #include <KWayland/Client/output.h> | ||
27 | #include <KWayland/Client/xdgoutput.h> | ||||
27 | #include <KWayland/Client/registry.h> | 28 | #include <KWayland/Client/registry.h> | ||
28 | 29 | | |||
29 | using namespace KWin; | 30 | using namespace KWin; | ||
30 | using namespace KWayland::Client; | 31 | using namespace KWayland::Client; | ||
31 | 32 | | |||
32 | static const QString s_socketName = QStringLiteral("wayland_test_kwin_screen_changes-0"); | 33 | static const QString s_socketName = QStringLiteral("wayland_test_kwin_screen_changes-0"); | ||
33 | 34 | | |||
34 | class ScreenChangesTest : public QObject | 35 | class ScreenChangesTest : public QObject | ||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 73 | { | |||
79 | QSignalSpy outputAnnouncedSpy(®istry, &Registry::outputAnnounced); | 80 | QSignalSpy outputAnnouncedSpy(®istry, &Registry::outputAnnounced); | ||
80 | QVERIFY(outputAnnouncedSpy.isValid()); | 81 | QVERIFY(outputAnnouncedSpy.isValid()); | ||
81 | QSignalSpy outputRemovedSpy(®istry, &Registry::outputRemoved); | 82 | QSignalSpy outputRemovedSpy(®istry, &Registry::outputRemoved); | ||
82 | QVERIFY(outputRemovedSpy.isValid()); | 83 | QVERIFY(outputRemovedSpy.isValid()); | ||
83 | registry.create(Test::waylandConnection()); | 84 | registry.create(Test::waylandConnection()); | ||
84 | QVERIFY(registry.isValid()); | 85 | QVERIFY(registry.isValid()); | ||
85 | registry.setup(); | 86 | registry.setup(); | ||
86 | QVERIFY(allAnnounced.wait()); | 87 | QVERIFY(allAnnounced.wait()); | ||
88 | const auto xdgOMData = registry.interface(Registry::Interface::XdgOutputUnstableV1); | ||||
89 | auto xdgOutputManager = registry.createXdgOutputManager(xdgOMData.name, xdgOMData.version); | ||||
87 | 90 | | |||
88 | // should be one output | 91 | // should be one output | ||
89 | QCOMPARE(screens()->count(), 1); | 92 | QCOMPARE(screens()->count(), 1); | ||
90 | QCOMPARE(outputAnnouncedSpy.count(), 1); | 93 | QCOMPARE(outputAnnouncedSpy.count(), 1); | ||
91 | const quint32 firstOutputId = outputAnnouncedSpy.first().first().value<quint32>(); | 94 | const quint32 firstOutputId = outputAnnouncedSpy.first().first().value<quint32>(); | ||
92 | QVERIFY(firstOutputId != 0u); | 95 | QVERIFY(firstOutputId != 0u); | ||
93 | outputAnnouncedSpy.clear(); | 96 | outputAnnouncedSpy.clear(); | ||
94 | 97 | | |||
Show All 38 Lines | |||||
133 | QCOMPARE(o1->geometry(), geometries.at(0)); | 136 | QCOMPARE(o1->geometry(), geometries.at(0)); | ||
134 | QScopedPointer<Output> o2(registry.createOutput(outputAnnouncedSpy.last().first().value<quint32>(), outputAnnouncedSpy.last().last().value<quint32>())); | 137 | QScopedPointer<Output> o2(registry.createOutput(outputAnnouncedSpy.last().first().value<quint32>(), outputAnnouncedSpy.last().last().value<quint32>())); | ||
135 | QVERIFY(o2->isValid()); | 138 | QVERIFY(o2->isValid()); | ||
136 | QSignalSpy o2ChangedSpy(o2.data(), &Output::changed); | 139 | QSignalSpy o2ChangedSpy(o2.data(), &Output::changed); | ||
137 | QVERIFY(o2ChangedSpy.isValid()); | 140 | QVERIFY(o2ChangedSpy.isValid()); | ||
138 | QVERIFY(o2ChangedSpy.wait()); | 141 | QVERIFY(o2ChangedSpy.wait()); | ||
139 | QCOMPARE(o2->geometry(), geometries.at(1)); | 142 | QCOMPARE(o2->geometry(), geometries.at(1)); | ||
140 | 143 | | |||
144 | //and check XDGOutput is synced | ||||
145 | QScopedPointer<XdgOutput> xdgO1(xdgOutputManager->getXdgOutput(o1.data())); | ||||
146 | QSignalSpy xdgO1ChangedSpy(xdgO1.data(), &XdgOutput::changed); | ||||
147 | QVERIFY(xdgO1ChangedSpy.isValid()); | ||||
148 | QVERIFY(xdgO1ChangedSpy.wait()); | ||||
149 | QCOMPARE(xdgO1->logicalPosition(), geometries.at(0).topLeft()); | ||||
150 | QCOMPARE(xdgO1->logicalSize(), geometries.at(0).size()); | ||||
151 | QScopedPointer<XdgOutput> xdgO2(xdgOutputManager->getXdgOutput(o2.data())); | ||||
152 | QSignalSpy xdgO2ChangedSpy(xdgO2.data(), &XdgOutput::changed); | ||||
153 | QVERIFY(xdgO2ChangedSpy.isValid()); | ||||
154 | QVERIFY(xdgO2ChangedSpy.wait()); | ||||
155 | QCOMPARE(xdgO2->logicalPosition(), geometries.at(1).topLeft()); | ||||
156 | QCOMPARE(xdgO2->logicalSize(), geometries.at(1).size()); | ||||
157 | | ||||
141 | // now let's try to remove one output again | 158 | // now let's try to remove one output again | ||
142 | outputAnnouncedSpy.clear(); | 159 | outputAnnouncedSpy.clear(); | ||
143 | outputRemovedSpy.clear(); | 160 | outputRemovedSpy.clear(); | ||
144 | screensChangedSpy.clear(); | 161 | screensChangedSpy.clear(); | ||
145 | 162 | | |||
146 | QSignalSpy o1RemovedSpy(o1.data(), &Output::removed); | 163 | QSignalSpy o1RemovedSpy(o1.data(), &Output::removed); | ||
147 | QVERIFY(o1RemovedSpy.isValid()); | 164 | QVERIFY(o1RemovedSpy.isValid()); | ||
148 | QSignalSpy o2RemovedSpy(o2.data(), &Output::removed); | 165 | QSignalSpy o2RemovedSpy(o2.data(), &Output::removed); | ||
Show All 30 Lines |