Changeset View
Changeset View
Standalone View
Standalone View
autotests/client/test_wayland_output.cpp
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 39 | private Q_SLOTS: | |||
---|---|---|---|---|---|
48 | void testSubPixel(); | 48 | void testSubPixel(); | ||
49 | 49 | | |||
50 | void testTransform_data(); | 50 | void testTransform_data(); | ||
51 | void testTransform(); | 51 | void testTransform(); | ||
52 | 52 | | |||
53 | void testDpms_data(); | 53 | void testDpms_data(); | ||
54 | void testDpms(); | 54 | void testDpms(); | ||
55 | 55 | | |||
56 | void testDpmsRequestMode_data(); | ||||
57 | void testDpmsRequestMode(); | ||||
58 | | ||||
56 | private: | 59 | private: | ||
57 | KWayland::Server::Display *m_display; | 60 | KWayland::Server::Display *m_display; | ||
58 | KWayland::Server::OutputInterface *m_serverOutput; | 61 | KWayland::Server::OutputInterface *m_serverOutput; | ||
59 | KWayland::Client::ConnectionThread *m_connection; | 62 | KWayland::Client::ConnectionThread *m_connection; | ||
60 | KWayland::Client::EventQueue *m_queue; | 63 | KWayland::Client::EventQueue *m_queue; | ||
61 | QThread *m_thread; | 64 | QThread *m_thread; | ||
62 | }; | 65 | }; | ||
63 | 66 | | |||
▲ Show 20 Lines • Show All 403 Lines • ▼ Show 20 Line(s) | 420 | { | |||
467 | QFETCH(OutputInterface::DpmsMode, server); | 470 | QFETCH(OutputInterface::DpmsMode, server); | ||
468 | m_serverOutput->setDpmsMode(server); | 471 | m_serverOutput->setDpmsMode(server); | ||
469 | QCOMPARE(m_serverOutput->dpmsMode(), server); | 472 | QCOMPARE(m_serverOutput->dpmsMode(), server); | ||
470 | QCOMPARE(serverDpmsModeChangedSpy.count(), 1); | 473 | QCOMPARE(serverDpmsModeChangedSpy.count(), 1); | ||
471 | 474 | | |||
472 | QVERIFY(clientDpmsModeChangedSpy.wait()); | 475 | QVERIFY(clientDpmsModeChangedSpy.wait()); | ||
473 | QCOMPARE(clientDpmsModeChangedSpy.count(), 1); | 476 | QCOMPARE(clientDpmsModeChangedSpy.count(), 1); | ||
474 | QTEST(dpms->mode(), "client"); | 477 | QTEST(dpms->mode(), "client"); | ||
478 | | ||||
479 | // test supported changed | ||||
sebas: Could be even more extensive: Switch On/Off with unsupported, setting unsupported when it's… | |||||
480 | QSignalSpy supportedChangedSpy(dpms, &Dpms::supportedChanged); | ||||
481 | QVERIFY(supportedChangedSpy.isValid()); | ||||
482 | m_serverOutput->setDpmsSupported(false); | ||||
483 | QVERIFY(supportedChangedSpy.wait()); | ||||
484 | QCOMPARE(supportedChangedSpy.count(), 1); | ||||
485 | QVERIFY(!dpms->isSupported()); | ||||
486 | m_serverOutput->setDpmsSupported(true); | ||||
487 | QVERIFY(supportedChangedSpy.wait()); | ||||
488 | QCOMPARE(supportedChangedSpy.count(), 2); | ||||
489 | QVERIFY(dpms->isSupported()); | ||||
490 | | ||||
491 | // and switch back to on | ||||
492 | m_serverOutput->setDpmsMode(OutputInterface::DpmsMode::On); | ||||
493 | QVERIFY(clientDpmsModeChangedSpy.wait()); | ||||
494 | QCOMPARE(clientDpmsModeChangedSpy.count(), 2); | ||||
495 | QCOMPARE(dpms->mode(), Dpms::Mode::On); | ||||
496 | } | ||||
497 | | ||||
498 | void TestWaylandOutput::testDpmsRequestMode_data() | ||||
499 | { | ||||
500 | using namespace KWayland::Client; | ||||
501 | using namespace KWayland::Server; | ||||
502 | | ||||
503 | QTest::addColumn<KWayland::Client::Dpms::Mode>("client"); | ||||
504 | QTest::addColumn<KWayland::Server::OutputInterface::DpmsMode>("server"); | ||||
505 | | ||||
506 | QTest::newRow("Standby") << Dpms::Mode::Standby << OutputInterface::DpmsMode::Standby; | ||||
507 | QTest::newRow("Suspend") << Dpms::Mode::Suspend << OutputInterface::DpmsMode::Suspend; | ||||
508 | QTest::newRow("Off") << Dpms::Mode::Off << OutputInterface::DpmsMode::Off; | ||||
509 | QTest::newRow("On") << Dpms::Mode::On << OutputInterface::DpmsMode::On; | ||||
510 | } | ||||
511 | | ||||
512 | void TestWaylandOutput::testDpmsRequestMode() | ||||
513 | { | ||||
514 | // this test verifies that requesting a dpms change from client side emits the signal on server side | ||||
515 | using namespace KWayland::Client; | ||||
516 | using namespace KWayland::Server; | ||||
517 | | ||||
518 | // setup code | ||||
519 | m_display->createDpmsManager()->create(); | ||||
520 | | ||||
521 | // set Dpms on the Output | ||||
522 | QSignalSpy serverDpmsSupportedChangedSpy(m_serverOutput, &OutputInterface::dpmsSupportedChanged); | ||||
523 | QVERIFY(serverDpmsSupportedChangedSpy.isValid()); | ||||
524 | QCOMPARE(m_serverOutput->isDpmsSupported(), false); | ||||
525 | m_serverOutput->setDpmsSupported(true); | ||||
526 | QCOMPARE(serverDpmsSupportedChangedSpy.count(), 1); | ||||
527 | QCOMPARE(m_serverOutput->isDpmsSupported(), true); | ||||
528 | | ||||
529 | KWayland::Client::Registry registry; | ||||
530 | registry.setEventQueue(m_queue); | ||||
531 | QSignalSpy announced(®istry, &Registry::interfacesAnnounced); | ||||
532 | QVERIFY(announced.isValid()); | ||||
533 | QSignalSpy dpmsAnnouncedSpy(®istry, &Registry::dpmsAnnounced); | ||||
534 | QVERIFY(dpmsAnnouncedSpy.isValid()); | ||||
535 | registry.create(m_connection->display()); | ||||
536 | QVERIFY(registry.isValid()); | ||||
537 | registry.setup(); | ||||
538 | m_connection->flush(); | ||||
539 | QVERIFY(announced.wait()); | ||||
540 | QCOMPARE(dpmsAnnouncedSpy.count(), 1); | ||||
541 | | ||||
542 | Output *output = registry.createOutput(registry.interface(Registry::Interface::Output).name, registry.interface(Registry::Interface::Output).version, ®istry); | ||||
543 | | ||||
544 | DpmsManager *dpmsManager = registry.createDpmsManager(dpmsAnnouncedSpy.first().first().value<quint32>(), dpmsAnnouncedSpy.first().last().value<quint32>(), ®istry); | ||||
545 | QVERIFY(dpmsManager->isValid()); | ||||
546 | | ||||
547 | Dpms *dpms = dpmsManager->getDpms(output, ®istry); | ||||
548 | // and test request mode | ||||
549 | QSignalSpy modeRequestedSpy(m_serverOutput, &OutputInterface::dpmsModeRequested); | ||||
550 | QVERIFY(modeRequestedSpy.isValid()); | ||||
551 | | ||||
552 | QFETCH(Dpms::Mode, client); | ||||
553 | dpms->requestMode(client); | ||||
554 | QVERIFY(modeRequestedSpy.wait()); | ||||
555 | QTEST(modeRequestedSpy.last().first().value<OutputInterface::DpmsMode>(), "server"); | ||||
475 | } | 556 | } | ||
476 | 557 | | |||
477 | QTEST_GUILESS_MAIN(TestWaylandOutput) | 558 | QTEST_GUILESS_MAIN(TestWaylandOutput) | ||
478 | #include "test_wayland_output.moc" | 559 | #include "test_wayland_output.moc" |
Could be even more extensive: Switch On/Off with unsupported, setting unsupported when it's already unsupported and checking the signal doesn't fire. (Suggestions for further improvements, no stopper for this review.)