Changeset View
Changeset View
Standalone View
Standalone View
autotests/testkwaylanddpms.cpp
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | 49 | private Q_SLOTS: | |||
---|---|---|---|---|---|
50 | 50 | | |||
51 | void initTestCase(); | 51 | void initTestCase(); | ||
52 | void cleanupTestCase(); | 52 | void cleanupTestCase(); | ||
53 | void testDpmsConnect(); | 53 | void testDpmsConnect(); | ||
54 | 54 | | |||
55 | private: | 55 | private: | ||
56 | ConnectionThread *m_connection; | 56 | ConnectionThread *m_connection; | ||
57 | QThread *m_thread; | 57 | QThread *m_thread; | ||
58 | Registry m_registry; | 58 | Registry *m_registry; | ||
59 | 59 | | |||
60 | KScreen::WaylandTestServer *m_server; | 60 | KScreen::WaylandTestServer *m_server; | ||
61 | }; | 61 | }; | ||
62 | 62 | | |||
63 | TestDpmsClient::TestDpmsClient(QObject *parent) | 63 | TestDpmsClient::TestDpmsClient(QObject *parent) | ||
64 | : QObject(parent) | 64 | : QObject(parent) | ||
65 | , m_server(nullptr) | 65 | , m_server(nullptr) | ||
66 | { | 66 | { | ||
Show All 17 Lines | 73 | { | |||
84 | m_connection->initConnection(); | 84 | m_connection->initConnection(); | ||
85 | QVERIFY(connectedSpy.wait()); | 85 | QVERIFY(connectedSpy.wait()); | ||
86 | 86 | | |||
87 | QSignalSpy dpmsSpy(this, &TestDpmsClient::dpmsAnnounced); | 87 | QSignalSpy dpmsSpy(this, &TestDpmsClient::dpmsAnnounced); | ||
88 | 88 | | |||
89 | m_connection->initConnection(); | 89 | m_connection->initConnection(); | ||
90 | QVERIFY(connectedSpy.wait(100)); | 90 | QVERIFY(connectedSpy.wait(100)); | ||
91 | 91 | | |||
92 | m_registry.create(m_connection); | 92 | m_registry = new KWayland::Client::Registry; | ||
93 | QObject::connect(&m_registry, &Registry::interfacesAnnounced, this, | 93 | m_registry->create(m_connection); | ||
94 | QObject::connect(m_registry, &Registry::interfacesAnnounced, this, | ||||
94 | [this] { | 95 | [this] { | ||
95 | const bool hasDpms = m_registry.hasInterface(Registry::Interface::Dpms); | 96 | const bool hasDpms = m_registry->hasInterface(Registry::Interface::Dpms); | ||
96 | if (hasDpms) { | 97 | if (hasDpms) { | ||
97 | qDebug() << QStringLiteral("Compositor provides a DpmsManager"); | 98 | qDebug() << QStringLiteral("Compositor provides a DpmsManager"); | ||
98 | } else { | 99 | } else { | ||
99 | qDebug() << QStringLiteral("Compositor does not provid a DpmsManager"); | 100 | qDebug() << QStringLiteral("Compositor does not provid a DpmsManager"); | ||
100 | } | 101 | } | ||
101 | emit this->dpmsAnnounced(); | 102 | emit this->dpmsAnnounced(); | ||
102 | }); | 103 | }); | ||
103 | m_registry.setup(); | 104 | m_registry->setup(); | ||
104 | 105 | | |||
105 | QVERIFY(dpmsSpy.wait(100)); | 106 | QVERIFY(dpmsSpy.wait(100)); | ||
106 | } | 107 | } | ||
107 | 108 | | |||
108 | void TestDpmsClient::cleanupTestCase() | 109 | void TestDpmsClient::cleanupTestCase() | ||
109 | { | 110 | { | ||
110 | m_thread->exit(); | 111 | m_thread->exit(); | ||
111 | m_thread->wait(); | 112 | m_thread->wait(); | ||
113 | delete m_registry; | ||||
112 | delete m_thread; | 114 | delete m_thread; | ||
113 | delete m_connection; | 115 | delete m_connection; | ||
114 | } | 116 | } | ||
115 | 117 | | |||
116 | void TestDpmsClient::testDpmsConnect() | 118 | void TestDpmsClient::testDpmsConnect() | ||
117 | { | 119 | { | ||
118 | QVERIFY(m_registry.isValid()); | 120 | QVERIFY(m_registry->isValid()); | ||
119 | } | 121 | } | ||
120 | 122 | | |||
121 | 123 | | |||
122 | QTEST_GUILESS_MAIN(TestDpmsClient) | 124 | QTEST_GUILESS_MAIN(TestDpmsClient) | ||
123 | 125 | | |||
124 | #include "testkwaylanddpms.moc" | 126 | #include "testkwaylanddpms.moc" |