Commit 423f4e7c authored by Martin Flöser's avatar Martin Flöser
Browse files

[autotests] Extend tests for Dpms

REVIEW: 125018
parent 23f4a639
......@@ -22,9 +22,11 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
// KWin
#include "../../src/client/connection_thread.h"
#include "../../src/client/event_queue.h"
#include "../../src/client/dpms.h"
#include "../../src/client/output.h"
#include "../../src/client/registry.h"
#include "../../src/server/display.h"
#include "../../src/server/dpms_interface.h"
#include "../../src/server/output_interface.h"
// Wayland
#include <wayland-client-protocol.h>
......@@ -48,6 +50,9 @@ private Q_SLOTS:
void testTransform_data();
void testTransform();
void testDpms_data();
void testDpms();
private:
KWayland::Server::Display *m_display;
KWayland::Server::OutputInterface *m_serverOutput;
......@@ -82,6 +87,8 @@ void TestWaylandOutput::init()
m_serverOutput->addMode(QSize(1280, 1024), OutputInterface::ModeFlags(), 90000);
m_serverOutput->setCurrentMode(QSize(1024, 768));
m_serverOutput->create();
QCOMPARE(m_serverOutput->isDpmsSupported(), false);
QCOMPARE(m_serverOutput->dpmsMode(), OutputInterface::DpmsMode::On);
// setup connection
m_connection = new KWayland::Client::ConnectionThread;
......@@ -393,5 +400,79 @@ void TestWaylandOutput::testTransform()
QCOMPARE(output->transform(), Output::Transform::Normal);
}
void TestWaylandOutput::testDpms_data()
{
using namespace KWayland::Client;
using namespace KWayland::Server;
QTest::addColumn<KWayland::Client::Dpms::Mode>("client");
QTest::addColumn<KWayland::Server::OutputInterface::DpmsMode>("server");
QTest::newRow("Standby") << Dpms::Mode::Standby << OutputInterface::DpmsMode::Standby;
QTest::newRow("Suspend") << Dpms::Mode::Suspend << OutputInterface::DpmsMode::Suspend;
QTest::newRow("Off") << Dpms::Mode::Off << OutputInterface::DpmsMode::Off;
}
void TestWaylandOutput::testDpms()
{
using namespace KWayland::Client;
using namespace KWayland::Server;
m_display->createDpmsManager()->create();
// set Dpms on the Output
QSignalSpy serverDpmsSupportedChangedSpy(m_serverOutput, &OutputInterface::dpmsSupportedChanged);
QVERIFY(serverDpmsSupportedChangedSpy.isValid());
QCOMPARE(m_serverOutput->isDpmsSupported(), false);
m_serverOutput->setDpmsSupported(true);
QCOMPARE(serverDpmsSupportedChangedSpy.count(), 1);
QCOMPARE(m_serverOutput->isDpmsSupported(), true);
KWayland::Client::Registry registry;
registry.setEventQueue(m_queue);
QSignalSpy announced(&registry, &Registry::interfacesAnnounced);
QVERIFY(announced.isValid());
QSignalSpy dpmsAnnouncedSpy(&registry, &Registry::dpmsAnnounced);
QVERIFY(dpmsAnnouncedSpy.isValid());
registry.create(m_connection->display());
QVERIFY(registry.isValid());
registry.setup();
m_connection->flush();
QVERIFY(announced.wait());
QCOMPARE(dpmsAnnouncedSpy.count(), 1);
Output *output = registry.createOutput(registry.interface(Registry::Interface::Output).name, registry.interface(Registry::Interface::Output).version, &registry);
DpmsManager *dpmsManager = registry.createDpmsManager(dpmsAnnouncedSpy.first().first().value<quint32>(), dpmsAnnouncedSpy.first().last().value<quint32>(), &registry);
QVERIFY(dpmsManager->isValid());
Dpms *dpms = dpmsManager->getDpms(output, &registry);
QSignalSpy clientDpmsSupportedChangedSpy(dpms, &Dpms::supportedChanged);
QVERIFY(clientDpmsSupportedChangedSpy.isValid());
QVERIFY(dpms->isValid());
QCOMPARE(dpms->isSupported(), false);
QCOMPARE(dpms->mode(), Dpms::Mode::On);
m_connection->flush();
QVERIFY(clientDpmsSupportedChangedSpy.wait());
QCOMPARE(clientDpmsSupportedChangedSpy.count(), 1);
QCOMPARE(dpms->isSupported(), true);
// and let's change to suspend
QSignalSpy serverDpmsModeChangedSpy(m_serverOutput, &OutputInterface::dpmsModeChanged);
QVERIFY(serverDpmsModeChangedSpy.isValid());
QSignalSpy clientDpmsModeChangedSpy(dpms, &Dpms::modeChanged);
QVERIFY(clientDpmsModeChangedSpy.isValid());
QCOMPARE(m_serverOutput->dpmsMode(), OutputInterface::DpmsMode::On);
QFETCH(OutputInterface::DpmsMode, server);
m_serverOutput->setDpmsMode(server);
QCOMPARE(m_serverOutput->dpmsMode(), server);
QCOMPARE(serverDpmsModeChangedSpy.count(), 1);
QVERIFY(clientDpmsModeChangedSpy.wait());
QCOMPARE(clientDpmsModeChangedSpy.count(), 1);
QTEST(dpms->mode(), "client");
}
QTEST_GUILESS_MAIN(TestWaylandOutput)
#include "test_wayland_output.moc"
......@@ -22,6 +22,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
// KWin
#include "../../src/client/compositor.h"
#include "../../src/client/connection_thread.h"
#include "../../src/client/dpms.h"
#include "../../src/client/event_queue.h"
#include "../../src/client/registry.h"
#include "../../src/client/output.h"
......@@ -31,6 +32,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
#include "../../src/server/compositor_interface.h"
#include "../../src/server/datadevicemanager_interface.h"
#include "../../src/server/display.h"
#include "../../src/server/dpms_interface.h"
#include "../../src/server/output_interface.h"
#include "../../src/server/seat_interface.h"
#include "../../src/server/shell_interface.h"
......@@ -40,6 +42,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
#include "../../src/server/subcompositor_interface.h"
// Wayland
#include <wayland-client-protocol.h>
#include <wayland-dpms-client-protocol.h>
class TestWaylandRegistry : public QObject
{
......@@ -61,6 +64,7 @@ private Q_SLOTS:
void testBindBlurManager();
void testBindContrastManager();
void testBindSlideManager();
void testBindDpmsManager();
void testGlobalSync();
void testGlobalSyncThreaded();
void testRemoval();
......@@ -112,6 +116,7 @@ void TestWaylandRegistry::init()
m_display->createBlurManager(this)->create();
m_display->createContrastManager(this)->create();
m_display->createSlideManager(this)->create();
m_display->createDpmsManager()->create();
}
void TestWaylandRegistry::cleanup()
......@@ -229,6 +234,11 @@ void TestWaylandRegistry::testBindSlideManager()
TEST_BIND(KWayland::Client::Registry::Interface::Slide, SIGNAL(slideAnnounced(quint32,quint32)), bindSlideManager, free)
}
void TestWaylandRegistry::testBindDpmsManager()
{
TEST_BIND(KWayland::Client::Registry::Interface::Dpms, SIGNAL(dpmsAnnounced(quint32,quint32)), bindDpmsManager, org_kde_kwin_dpms_manager_destroy)
}
#undef TEST_BIND
void TestWaylandRegistry::testRemoval()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment