Changeset View
Changeset View
Standalone View
Standalone View
autotests/client/test_wayland_outputdevice.cpp
Show All 38 Lines | |||||
39 | public: | 39 | public: | ||
40 | explicit TestWaylandOutputDevice(QObject *parent = nullptr); | 40 | explicit TestWaylandOutputDevice(QObject *parent = nullptr); | ||
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 | #if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50) | ||||
47 | void testScaleChange_legacy(); | 48 | void testScaleChange_legacy(); | ||
49 | #endif | ||||
48 | void testScaleChange(); | 50 | void testScaleChange(); | ||
49 | void testColorCurvesChange(); | 51 | void testColorCurvesChange(); | ||
50 | 52 | | |||
51 | void testSubPixel_data(); | 53 | void testSubPixel_data(); | ||
52 | void testSubPixel(); | 54 | void testSubPixel(); | ||
53 | 55 | | |||
54 | void testTransform_data(); | 56 | void testTransform_data(); | ||
55 | void testTransform(); | 57 | void testTransform(); | ||
▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Line(s) | 188 | { | |||
202 | QCOMPARE(output.uuid(), QByteArray()); | 204 | QCOMPARE(output.uuid(), QByteArray()); | ||
203 | QCOMPARE(output.geometry(), QRect()); | 205 | QCOMPARE(output.geometry(), QRect()); | ||
204 | QCOMPARE(output.globalPosition(), QPoint()); | 206 | QCOMPARE(output.globalPosition(), QPoint()); | ||
205 | QCOMPARE(output.manufacturer(), QString()); | 207 | QCOMPARE(output.manufacturer(), QString()); | ||
206 | QCOMPARE(output.model(), QString()); | 208 | QCOMPARE(output.model(), QString()); | ||
207 | QCOMPARE(output.physicalSize(), QSize()); | 209 | QCOMPARE(output.physicalSize(), QSize()); | ||
208 | QCOMPARE(output.pixelSize(), QSize()); | 210 | QCOMPARE(output.pixelSize(), QSize()); | ||
209 | QCOMPARE(output.refreshRate(), 0); | 211 | QCOMPARE(output.refreshRate(), 0); | ||
212 | #if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50) | ||||
210 | QCOMPARE(output.scale(), 1); | 213 | QCOMPARE(output.scale(), 1); | ||
214 | #endif | ||||
215 | QCOMPARE(output.scaleF(), 1.0); | ||||
211 | QCOMPARE(output.colorCurves().red, QVector<quint16>()); | 216 | QCOMPARE(output.colorCurves().red, QVector<quint16>()); | ||
212 | QCOMPARE(output.colorCurves().green, QVector<quint16>()); | 217 | QCOMPARE(output.colorCurves().green, QVector<quint16>()); | ||
213 | QCOMPARE(output.colorCurves().blue, QVector<quint16>()); | 218 | QCOMPARE(output.colorCurves().blue, QVector<quint16>()); | ||
214 | QCOMPARE(output.subPixel(), KWayland::Client::OutputDevice::SubPixel::Unknown); | 219 | QCOMPARE(output.subPixel(), KWayland::Client::OutputDevice::SubPixel::Unknown); | ||
215 | QCOMPARE(output.transform(), KWayland::Client::OutputDevice::Transform::Normal); | 220 | QCOMPARE(output.transform(), KWayland::Client::OutputDevice::Transform::Normal); | ||
216 | QCOMPARE(output.enabled(), OutputDevice::Enablement::Enabled); | 221 | QCOMPARE(output.enabled(), OutputDevice::Enablement::Enabled); | ||
217 | QCOMPARE(output.edid(), QByteArray()); | 222 | QCOMPARE(output.edid(), QByteArray()); | ||
218 | QCOMPARE(output.eisaId(), QString()); | 223 | QCOMPARE(output.eisaId(), QString()); | ||
Show All 9 Lines | |||||
228 | 233 | | |||
229 | QCOMPARE(output.geometry(), QRect(100, 50, 1024, 768)); | 234 | QCOMPARE(output.geometry(), QRect(100, 50, 1024, 768)); | ||
230 | QCOMPARE(output.globalPosition(), QPoint(100, 50)); | 235 | QCOMPARE(output.globalPosition(), QPoint(100, 50)); | ||
231 | QCOMPARE(output.manufacturer(), QStringLiteral("org.kde.kwin")); | 236 | QCOMPARE(output.manufacturer(), QStringLiteral("org.kde.kwin")); | ||
232 | QCOMPARE(output.model(), QStringLiteral("none")); | 237 | QCOMPARE(output.model(), QStringLiteral("none")); | ||
233 | QCOMPARE(output.physicalSize(), QSize(200, 100)); | 238 | QCOMPARE(output.physicalSize(), QSize(200, 100)); | ||
234 | QCOMPARE(output.pixelSize(), QSize(1024, 768)); | 239 | QCOMPARE(output.pixelSize(), QSize(1024, 768)); | ||
235 | QCOMPARE(output.refreshRate(), 60000); | 240 | QCOMPARE(output.refreshRate(), 60000); | ||
241 | #if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50) | ||||
236 | QCOMPARE(output.scale(), 1); | 242 | QCOMPARE(output.scale(), 1); | ||
243 | #endif | ||||
244 | QCOMPARE(output.scaleF(), 1.0); | ||||
237 | QCOMPARE(output.colorCurves().red, m_initColorCurves.red); | 245 | QCOMPARE(output.colorCurves().red, m_initColorCurves.red); | ||
238 | QCOMPARE(output.colorCurves().green, m_initColorCurves.green); | 246 | QCOMPARE(output.colorCurves().green, m_initColorCurves.green); | ||
239 | QCOMPARE(output.colorCurves().blue, m_initColorCurves.blue); | 247 | QCOMPARE(output.colorCurves().blue, m_initColorCurves.blue); | ||
240 | // for xwayland output it's unknown | 248 | // for xwayland output it's unknown | ||
241 | QCOMPARE(output.subPixel(), KWayland::Client::OutputDevice::SubPixel::Unknown); | 249 | QCOMPARE(output.subPixel(), KWayland::Client::OutputDevice::SubPixel::Unknown); | ||
242 | // for xwayland transform is normal | 250 | // for xwayland transform is normal | ||
243 | QCOMPARE(output.transform(), KWayland::Client::OutputDevice::Transform::Normal); | 251 | QCOMPARE(output.transform(), KWayland::Client::OutputDevice::Transform::Normal); | ||
244 | 252 | | |||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Line(s) | 261 | { | |||
341 | // the one which got the current flag | 349 | // the one which got the current flag | ||
342 | QCOMPARE(modeChangedSpy.last().first().value<OutputDevice::Mode>().size, QSize(1280, 1024)); | 350 | QCOMPARE(modeChangedSpy.last().first().value<OutputDevice::Mode>().size, QSize(1280, 1024)); | ||
343 | QCOMPARE(modeChangedSpy.last().first().value<OutputDevice::Mode>().refreshRate, 90000); | 351 | QCOMPARE(modeChangedSpy.last().first().value<OutputDevice::Mode>().refreshRate, 90000); | ||
344 | QCOMPARE(modeChangedSpy.last().first().value<OutputDevice::Mode>().flags, OutputDevice::Mode::Flags(OutputDevice::Mode::Flag::Current)); | 352 | QCOMPARE(modeChangedSpy.last().first().value<OutputDevice::Mode>().flags, OutputDevice::Mode::Flags(OutputDevice::Mode::Flag::Current)); | ||
345 | QVERIFY(!outputChanged.isEmpty()); | 353 | QVERIFY(!outputChanged.isEmpty()); | ||
346 | QCOMPARE(output.pixelSize(), QSize(1280, 1024)); | 354 | QCOMPARE(output.pixelSize(), QSize(1280, 1024)); | ||
347 | } | 355 | } | ||
348 | 356 | | |||
357 | #if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50) | ||||
349 | void TestWaylandOutputDevice::testScaleChange_legacy() | 358 | void TestWaylandOutputDevice::testScaleChange_legacy() | ||
350 | { | 359 | { | ||
351 | KWayland::Client::Registry registry; | 360 | KWayland::Client::Registry registry; | ||
352 | QSignalSpy interfacesAnnouncedSpy(®istry, &KWayland::Client::Registry::interfacesAnnounced); | 361 | QSignalSpy interfacesAnnouncedSpy(®istry, &KWayland::Client::Registry::interfacesAnnounced); | ||
353 | QVERIFY(interfacesAnnouncedSpy.isValid()); | 362 | QVERIFY(interfacesAnnouncedSpy.isValid()); | ||
354 | QSignalSpy announced(®istry, &KWayland::Client::Registry::outputDeviceAnnounced); | 363 | QSignalSpy announced(®istry, &KWayland::Client::Registry::outputDeviceAnnounced); | ||
355 | registry.setEventQueue(m_queue); | 364 | registry.setEventQueue(m_queue); | ||
356 | registry.create(m_connection->display()); | 365 | registry.create(m_connection->display()); | ||
357 | QVERIFY(registry.isValid()); | 366 | QVERIFY(registry.isValid()); | ||
358 | registry.setup(); | 367 | registry.setup(); | ||
359 | wl_display_flush(m_connection->display()); | 368 | wl_display_flush(m_connection->display()); | ||
360 | QVERIFY(interfacesAnnouncedSpy.wait()); | 369 | QVERIFY(interfacesAnnouncedSpy.wait()); | ||
361 | 370 | | |||
362 | KWayland::Client::OutputDevice output; | 371 | KWayland::Client::OutputDevice output; | ||
363 | QSignalSpy outputChanged(&output, &KWayland::Client::OutputDevice::done); | 372 | QSignalSpy outputChanged(&output, &KWayland::Client::OutputDevice::done); | ||
364 | QVERIFY(outputChanged.isValid()); | 373 | QVERIFY(outputChanged.isValid()); | ||
365 | output.setup(registry.bindOutputDevice(announced.first().first().value<quint32>(), announced.first().last().value<quint32>())); | 374 | output.setup(registry.bindOutputDevice(announced.first().first().value<quint32>(), announced.first().last().value<quint32>())); | ||
366 | wl_display_flush(m_connection->display()); | 375 | wl_display_flush(m_connection->display()); | ||
367 | QVERIFY(outputChanged.wait()); | 376 | QVERIFY(outputChanged.wait()); | ||
368 | QCOMPARE(output.scale(), 1); | 377 | QCOMPARE(output.scale(), 1); | ||
378 | QCOMPARE(output.scaleF(), 1.0); | ||||
369 | 379 | | |||
370 | // change the scale | 380 | // change the scale | ||
371 | outputChanged.clear(); | 381 | outputChanged.clear(); | ||
372 | m_serverOutputDevice->setScale(2); | 382 | m_serverOutputDevice->setScale(2); | ||
373 | QVERIFY(outputChanged.wait()); | 383 | QVERIFY(outputChanged.wait()); | ||
374 | QCOMPARE(output.scale(), 2); | 384 | QCOMPARE(output.scale(), 2); | ||
375 | QCOMPARE(output.scaleF(), 2.0); //check we're forward compatible | 385 | QCOMPARE(output.scaleF(), 2.0); //check we're forward compatible | ||
376 | 386 | | |||
377 | 387 | | |||
378 | // change once more | 388 | // change once more | ||
379 | outputChanged.clear(); | 389 | outputChanged.clear(); | ||
380 | m_serverOutputDevice->setScale(4); | 390 | m_serverOutputDevice->setScale(4); | ||
381 | QVERIFY(outputChanged.wait()); | 391 | QVERIFY(outputChanged.wait()); | ||
382 | QCOMPARE(output.scale(), 4); | 392 | QCOMPARE(output.scale(), 4); | ||
383 | QCOMPARE(output.scaleF(), 4.0); | 393 | QCOMPARE(output.scaleF(), 4.0); | ||
384 | } | 394 | } | ||
395 | #endif | ||||
385 | 396 | | |||
386 | void TestWaylandOutputDevice::testScaleChange() | 397 | void TestWaylandOutputDevice::testScaleChange() | ||
387 | { | 398 | { | ||
388 | KWayland::Client::Registry registry; | 399 | KWayland::Client::Registry registry; | ||
389 | QSignalSpy interfacesAnnouncedSpy(®istry, &KWayland::Client::Registry::interfacesAnnounced); | 400 | QSignalSpy interfacesAnnouncedSpy(®istry, &KWayland::Client::Registry::interfacesAnnounced); | ||
390 | QVERIFY(interfacesAnnouncedSpy.isValid()); | 401 | QVERIFY(interfacesAnnouncedSpy.isValid()); | ||
391 | QSignalSpy announced(®istry, &KWayland::Client::Registry::outputDeviceAnnounced); | 402 | QSignalSpy announced(®istry, &KWayland::Client::Registry::outputDeviceAnnounced); | ||
392 | registry.setEventQueue(m_queue); | 403 | registry.setEventQueue(m_queue); | ||
Show All 10 Lines | |||||
403 | wl_display_flush(m_connection->display()); | 414 | wl_display_flush(m_connection->display()); | ||
404 | QVERIFY(outputChanged.wait()); | 415 | QVERIFY(outputChanged.wait()); | ||
405 | QCOMPARE(output.scaleF(), 1.0); | 416 | QCOMPARE(output.scaleF(), 1.0); | ||
406 | 417 | | |||
407 | // change the scale | 418 | // change the scale | ||
408 | outputChanged.clear(); | 419 | outputChanged.clear(); | ||
409 | m_serverOutputDevice->setScaleF(2.2); | 420 | m_serverOutputDevice->setScaleF(2.2); | ||
410 | QVERIFY(outputChanged.wait()); | 421 | QVERIFY(outputChanged.wait()); | ||
422 | #if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50) | ||||
411 | QCOMPARE(output.scale(), 2); //check backwards compatibility works | 423 | QCOMPARE(output.scale(), 2); //check backwards compatibility works | ||
424 | #endif | ||||
412 | QCOMPARE(wl_fixed_from_double(output.scaleF()), wl_fixed_from_double(2.2)); | 425 | QCOMPARE(wl_fixed_from_double(output.scaleF()), wl_fixed_from_double(2.2)); | ||
413 | 426 | | |||
414 | // change once more | 427 | // change once more | ||
415 | outputChanged.clear(); | 428 | outputChanged.clear(); | ||
416 | m_serverOutputDevice->setScaleF(4.9); | 429 | m_serverOutputDevice->setScaleF(4.9); | ||
417 | QVERIFY(outputChanged.wait()); | 430 | QVERIFY(outputChanged.wait()); | ||
431 | #if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50) | ||||
418 | QCOMPARE(output.scale(), 5); | 432 | QCOMPARE(output.scale(), 5); | ||
433 | #endif | ||||
419 | QCOMPARE(wl_fixed_from_double(output.scaleF()), wl_fixed_from_double(4.9)); | 434 | QCOMPARE(wl_fixed_from_double(output.scaleF()), wl_fixed_from_double(4.9)); | ||
420 | } | 435 | } | ||
421 | 436 | | |||
422 | void TestWaylandOutputDevice::testColorCurvesChange() | 437 | void TestWaylandOutputDevice::testColorCurvesChange() | ||
423 | { | 438 | { | ||
424 | KWayland::Client::Registry registry; | 439 | KWayland::Client::Registry registry; | ||
425 | QSignalSpy interfacesAnnouncedSpy(®istry, &KWayland::Client::Registry::interfacesAnnounced); | 440 | QSignalSpy interfacesAnnouncedSpy(®istry, &KWayland::Client::Registry::interfacesAnnounced); | ||
426 | QVERIFY(interfacesAnnouncedSpy.isValid()); | 441 | QVERIFY(interfacesAnnouncedSpy.isValid()); | ||
▲ Show 20 Lines • Show All 269 Lines • Show Last 20 Lines |