Changeset View
Changeset View
Standalone View
Standalone View
autotests/client/test_wayland_outputdevice.cpp
Show All 40 Lines | |||||
41 | private Q_SLOTS: | 41 | private Q_SLOTS: | ||
42 | void init(); | 42 | void init(); | ||
43 | void cleanup(); | 43 | void cleanup(); | ||
44 | 44 | | |||
45 | void testRegistry(); | 45 | void testRegistry(); | ||
46 | void testModeChanges(); | 46 | void testModeChanges(); | ||
47 | void testScaleChange_legacy(); | 47 | void testScaleChange_legacy(); | ||
48 | void testScaleChange(); | 48 | void testScaleChange(); | ||
49 | void testColorCurvesChange(); | ||||
49 | 50 | | |||
50 | void testSubPixel_data(); | 51 | void testSubPixel_data(); | ||
51 | void testSubPixel(); | 52 | void testSubPixel(); | ||
52 | 53 | | |||
53 | void testTransform_data(); | 54 | void testTransform_data(); | ||
54 | void testTransform(); | 55 | void testTransform(); | ||
55 | 56 | | |||
56 | void testEnabled(); | 57 | void testEnabled(); | ||
57 | void testEdid(); | 58 | void testEdid(); | ||
58 | void testId(); | 59 | void testId(); | ||
59 | void testDone(); | 60 | void testDone(); | ||
60 | 61 | | |||
61 | private: | 62 | private: | ||
62 | KWayland::Server::Display *m_display; | 63 | KWayland::Server::Display *m_display; | ||
63 | KWayland::Server::OutputDeviceInterface *m_serverOutputDevice; | 64 | KWayland::Server::OutputDeviceInterface *m_serverOutputDevice; | ||
64 | QByteArray m_edid; | 65 | QByteArray m_edid; | ||
66 | KWayland::Server::OutputDeviceInterface::ColorCurves m_initColorCurves; | ||||
65 | KWayland::Client::ConnectionThread *m_connection; | 67 | KWayland::Client::ConnectionThread *m_connection; | ||
66 | KWayland::Client::EventQueue *m_queue; | 68 | KWayland::Client::EventQueue *m_queue; | ||
67 | QThread *m_thread; | 69 | QThread *m_thread; | ||
68 | 70 | | |||
69 | }; | 71 | }; | ||
70 | 72 | | |||
71 | static const QString s_socketName = QStringLiteral("kwin-test-wayland-output-0"); | 73 | static const QString s_socketName = QStringLiteral("kwin-test-wayland-output-0"); | ||
72 | 74 | | |||
Show All 37 Lines | 86 | { | |||
110 | m2.refreshRate = 90000; | 112 | m2.refreshRate = 90000; | ||
111 | m_serverOutputDevice->addMode(m2); | 113 | m_serverOutputDevice->addMode(m2); | ||
112 | 114 | | |||
113 | m_serverOutputDevice->setCurrentMode(1); | 115 | m_serverOutputDevice->setCurrentMode(1); | ||
114 | 116 | | |||
115 | m_edid = QByteArray::fromBase64("AP///////wAQrBbwTExLQQ4WAQOANCB46h7Frk80sSYOUFSlSwCBgKlA0QBxTwEBAQEBAQEBKDyAoHCwI0AwIDYABkQhAAAaAAAA/wBGNTI1TTI0NUFLTEwKAAAA/ABERUxMIFUyNDEwCiAgAAAA/QA4TB5REQAKICAgICAgAToCAynxUJAFBAMCBxYBHxITFCAVEQYjCQcHZwMMABAAOC2DAQAA4wUDAQI6gBhxOC1AWCxFAAZEIQAAHgEdgBhxHBYgWCwlAAZEIQAAngEdAHJR0B4gbihVAAZEIQAAHowK0Iog4C0QED6WAAZEIQAAGAAAAAAAAAAAAAAAAAAAPg=="); | 117 | m_edid = QByteArray::fromBase64("AP///////wAQrBbwTExLQQ4WAQOANCB46h7Frk80sSYOUFSlSwCBgKlA0QBxTwEBAQEBAQEBKDyAoHCwI0AwIDYABkQhAAAaAAAA/wBGNTI1TTI0NUFLTEwKAAAA/ABERUxMIFUyNDEwCiAgAAAA/QA4TB5REQAKICAgICAgAToCAynxUJAFBAMCBxYBHxITFCAVEQYjCQcHZwMMABAAOC2DAQAA4wUDAQI6gBhxOC1AWCxFAAZEIQAAHgEdgBhxHBYgWCwlAAZEIQAAngEdAHJR0B4gbihVAAZEIQAAHowK0Iog4C0QED6WAAZEIQAAGAAAAAAAAAAAAAAAAAAAPg=="); | ||
116 | m_serverOutputDevice->setEdid(m_edid); | 118 | m_serverOutputDevice->setEdid(m_edid); | ||
117 | 119 | | |||
120 | m_initColorCurves.red.clear(); | ||||
121 | m_initColorCurves.green.clear(); | ||||
122 | m_initColorCurves.blue.clear(); | ||||
123 | // 8 bit color ramps | ||||
124 | for (int i = 0; i < 256; i++) { | ||||
125 | quint16 val = (double)i / 255 * UINT16_MAX; | ||||
126 | m_initColorCurves.red << val ; | ||||
127 | m_initColorCurves.green << val ; | ||||
128 | } | ||||
129 | // 10 bit color ramp | ||||
130 | for (int i = 0; i < 320; i++) { | ||||
131 | m_initColorCurves.blue << (double)i / 319 * UINT16_MAX; | ||||
132 | } | ||||
133 | m_serverOutputDevice->setColorCurves(m_initColorCurves); | ||||
134 | | ||||
118 | m_serverOutputDevice->create(); | 135 | m_serverOutputDevice->create(); | ||
119 | 136 | | |||
120 | // setup connection | 137 | // setup connection | ||
121 | m_connection = new KWayland::Client::ConnectionThread; | 138 | m_connection = new KWayland::Client::ConnectionThread; | ||
122 | QSignalSpy connectedSpy(m_connection, &KWayland::Client::ConnectionThread::connected); | 139 | QSignalSpy connectedSpy(m_connection, &KWayland::Client::ConnectionThread::connected); | ||
123 | m_connection->setSocketName(s_socketName); | 140 | m_connection->setSocketName(s_socketName); | ||
124 | 141 | | |||
125 | m_thread = new QThread(this); | 142 | m_thread = new QThread(this); | ||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | 178 | { | |||
178 | QCOMPARE(output.geometry(), QRect()); | 195 | QCOMPARE(output.geometry(), QRect()); | ||
179 | QCOMPARE(output.globalPosition(), QPoint()); | 196 | QCOMPARE(output.globalPosition(), QPoint()); | ||
180 | QCOMPARE(output.manufacturer(), QString()); | 197 | QCOMPARE(output.manufacturer(), QString()); | ||
181 | QCOMPARE(output.model(), QString()); | 198 | QCOMPARE(output.model(), QString()); | ||
182 | QCOMPARE(output.physicalSize(), QSize()); | 199 | QCOMPARE(output.physicalSize(), QSize()); | ||
183 | QCOMPARE(output.pixelSize(), QSize()); | 200 | QCOMPARE(output.pixelSize(), QSize()); | ||
184 | QCOMPARE(output.refreshRate(), 0); | 201 | QCOMPARE(output.refreshRate(), 0); | ||
185 | QCOMPARE(output.scale(), 1); | 202 | QCOMPARE(output.scale(), 1); | ||
203 | QCOMPARE(output.colorCurves().red, QVector<quint16>()); | ||||
204 | QCOMPARE(output.colorCurves().green, QVector<quint16>()); | ||||
205 | QCOMPARE(output.colorCurves().blue, QVector<quint16>()); | ||||
186 | QCOMPARE(output.subPixel(), KWayland::Client::OutputDevice::SubPixel::Unknown); | 206 | QCOMPARE(output.subPixel(), KWayland::Client::OutputDevice::SubPixel::Unknown); | ||
187 | QCOMPARE(output.transform(), KWayland::Client::OutputDevice::Transform::Normal); | 207 | QCOMPARE(output.transform(), KWayland::Client::OutputDevice::Transform::Normal); | ||
188 | QCOMPARE(output.enabled(), OutputDevice::Enablement::Enabled); | 208 | QCOMPARE(output.enabled(), OutputDevice::Enablement::Enabled); | ||
189 | QCOMPARE(output.edid(), QByteArray()); | 209 | QCOMPARE(output.edid(), QByteArray()); | ||
190 | QSignalSpy outputChanged(&output, &KWayland::Client::OutputDevice::done); | 210 | QSignalSpy outputChanged(&output, &KWayland::Client::OutputDevice::done); | ||
191 | QVERIFY(outputChanged.isValid()); | 211 | QVERIFY(outputChanged.isValid()); | ||
192 | 212 | | |||
193 | output.setup(registry.bindOutputDevice(announced.first().first().value<quint32>(), announced.first().last().value<quint32>())); | 213 | output.setup(registry.bindOutputDevice(announced.first().first().value<quint32>(), announced.first().last().value<quint32>())); | ||
194 | wl_display_flush(m_connection->display()); | 214 | wl_display_flush(m_connection->display()); | ||
195 | 215 | | |||
196 | QVERIFY(outputChanged.wait()); | 216 | QVERIFY(outputChanged.wait()); | ||
197 | 217 | | |||
198 | QCOMPARE(output.geometry(), QRect(100, 50, 1024, 768)); | 218 | QCOMPARE(output.geometry(), QRect(100, 50, 1024, 768)); | ||
199 | QCOMPARE(output.globalPosition(), QPoint(100, 50)); | 219 | QCOMPARE(output.globalPosition(), QPoint(100, 50)); | ||
200 | QCOMPARE(output.manufacturer(), QStringLiteral("org.kde.kwin")); | 220 | QCOMPARE(output.manufacturer(), QStringLiteral("org.kde.kwin")); | ||
201 | QCOMPARE(output.model(), QStringLiteral("none")); | 221 | QCOMPARE(output.model(), QStringLiteral("none")); | ||
202 | QCOMPARE(output.physicalSize(), QSize(200, 100)); | 222 | QCOMPARE(output.physicalSize(), QSize(200, 100)); | ||
203 | QCOMPARE(output.pixelSize(), QSize(1024, 768)); | 223 | QCOMPARE(output.pixelSize(), QSize(1024, 768)); | ||
204 | QCOMPARE(output.refreshRate(), 60000); | 224 | QCOMPARE(output.refreshRate(), 60000); | ||
205 | QCOMPARE(output.scale(), 1); | 225 | QCOMPARE(output.scale(), 1); | ||
226 | QCOMPARE(output.colorCurves().red, m_initColorCurves.red); | ||||
227 | QCOMPARE(output.colorCurves().green, m_initColorCurves.green); | ||||
228 | QCOMPARE(output.colorCurves().blue, m_initColorCurves.blue); | ||||
206 | // for xwayland output it's unknown | 229 | // for xwayland output it's unknown | ||
207 | QCOMPARE(output.subPixel(), KWayland::Client::OutputDevice::SubPixel::Unknown); | 230 | QCOMPARE(output.subPixel(), KWayland::Client::OutputDevice::SubPixel::Unknown); | ||
208 | // for xwayland transform is normal | 231 | // for xwayland transform is normal | ||
209 | QCOMPARE(output.transform(), KWayland::Client::OutputDevice::Transform::Normal); | 232 | QCOMPARE(output.transform(), KWayland::Client::OutputDevice::Transform::Normal); | ||
210 | 233 | | |||
211 | QCOMPARE(output.edid(), m_edid); | 234 | QCOMPARE(output.edid(), m_edid); | ||
212 | QCOMPARE(output.enabled(), OutputDevice::Enablement::Enabled); | 235 | QCOMPARE(output.enabled(), OutputDevice::Enablement::Enabled); | ||
213 | QCOMPARE(output.uuid(), QByteArray("1337")); | 236 | QCOMPARE(output.uuid(), QByteArray("1337")); | ||
▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Line(s) | 375 | { | |||
379 | // change once more | 402 | // change once more | ||
380 | outputChanged.clear(); | 403 | outputChanged.clear(); | ||
381 | m_serverOutputDevice->setScaleF(4.9); | 404 | m_serverOutputDevice->setScaleF(4.9); | ||
382 | QVERIFY(outputChanged.wait()); | 405 | QVERIFY(outputChanged.wait()); | ||
383 | QCOMPARE(output.scale(), 5); | 406 | QCOMPARE(output.scale(), 5); | ||
384 | QCOMPARE(wl_fixed_from_double(output.scaleF()), wl_fixed_from_double(4.9)); | 407 | QCOMPARE(wl_fixed_from_double(output.scaleF()), wl_fixed_from_double(4.9)); | ||
385 | } | 408 | } | ||
386 | 409 | | |||
410 | void TestWaylandOutputDevice::testColorCurvesChange() | ||||
411 | { | ||||
412 | KWayland::Client::Registry registry; | ||||
413 | QSignalSpy interfacesAnnouncedSpy(®istry, &KWayland::Client::Registry::interfacesAnnounced); | ||||
414 | QVERIFY(interfacesAnnouncedSpy.isValid()); | ||||
415 | QSignalSpy announced(®istry, &KWayland::Client::Registry::outputDeviceAnnounced); | ||||
416 | registry.setEventQueue(m_queue); | ||||
417 | registry.create(m_connection->display()); | ||||
418 | QVERIFY(registry.isValid()); | ||||
419 | registry.setup(); | ||||
420 | wl_display_flush(m_connection->display()); | ||||
421 | QVERIFY(interfacesAnnouncedSpy.wait()); | ||||
422 | | ||||
423 | KWayland::Client::OutputDevice output; | ||||
424 | QSignalSpy outputChanged(&output, &KWayland::Client::OutputDevice::done); | ||||
425 | QVERIFY(outputChanged.isValid()); | ||||
426 | output.setup(registry.bindOutputDevice(announced.first().first().value<quint32>(), announced.first().last().value<quint32>())); | ||||
427 | wl_display_flush(m_connection->display()); | ||||
428 | QVERIFY(outputChanged.wait()); | ||||
429 | QCOMPARE(output.colorCurves().red, m_initColorCurves.red); | ||||
430 | QCOMPARE(output.colorCurves().green, m_initColorCurves.green); | ||||
431 | QCOMPARE(output.colorCurves().blue, m_initColorCurves.blue); | ||||
432 | | ||||
433 | // change the color curves | ||||
434 | outputChanged.clear(); | ||||
435 | KWayland::Server::OutputDeviceInterface::ColorCurves cc; | ||||
436 | cc.red = QVector<quint16>(256, 0); | ||||
437 | cc.green = QVector<quint16>(256, UINT16_MAX); | ||||
438 | cc.blue = QVector<quint16>(320, 1); | ||||
439 | m_serverOutputDevice->setColorCurves(cc); | ||||
440 | QVERIFY(outputChanged.wait()); | ||||
441 | QCOMPARE(output.colorCurves().red, cc.red); | ||||
442 | QCOMPARE(output.colorCurves().green, cc.green); | ||||
443 | QCOMPARE(output.colorCurves().blue, cc.blue); | ||||
444 | | ||||
445 | // change once more | ||||
446 | outputChanged.clear(); | ||||
447 | cc.red = QVector<quint16>(256, 0); | ||||
448 | cc.green = QVector<quint16>(256, UINT16_MAX); | ||||
449 | cc.blue = QVector<quint16>(320, UINT16_MAX); | ||||
450 | m_serverOutputDevice->setColorCurves(cc); | ||||
451 | QVERIFY(outputChanged.wait()); | ||||
452 | QCOMPARE(output.colorCurves().red, cc.red); | ||||
453 | QCOMPARE(output.colorCurves().green, cc.green); | ||||
454 | QCOMPARE(output.colorCurves().blue, cc.blue); | ||||
455 | } | ||||
456 | | ||||
387 | void TestWaylandOutputDevice::testSubPixel_data() | 457 | void TestWaylandOutputDevice::testSubPixel_data() | ||
388 | { | 458 | { | ||
389 | using namespace KWayland::Client; | 459 | using namespace KWayland::Client; | ||
390 | using namespace KWayland::Server; | 460 | using namespace KWayland::Server; | ||
391 | QTest::addColumn<KWayland::Client::OutputDevice::SubPixel>("expected"); | 461 | QTest::addColumn<KWayland::Client::OutputDevice::SubPixel>("expected"); | ||
392 | QTest::addColumn<KWayland::Server::OutputDeviceInterface::SubPixel>("actual"); | 462 | QTest::addColumn<KWayland::Server::OutputDeviceInterface::SubPixel>("actual"); | ||
393 | 463 | | |||
394 | QTest::newRow("none") << OutputDevice::SubPixel::None << OutputDeviceInterface::SubPixel::None; | 464 | QTest::newRow("none") << OutputDevice::SubPixel::None << OutputDeviceInterface::SubPixel::None; | ||
▲ Show 20 Lines • Show All 219 Lines • Show Last 20 Lines |