From 3d7e926c946ef9b50dc9439e49e87f8a74c4404d Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Sun, 30 Oct 2022 23:12:30 +0100 Subject: [PATCH] autotests/drm: add autotest for common modes --- autotests/drm/drmTest.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/autotests/drm/drmTest.cpp b/autotests/drm/drmTest.cpp index ec23185865..eb20abdf21 100644 --- a/autotests/drm/drmTest.cpp +++ b/autotests/drm/drmTest.cpp @@ -35,6 +35,7 @@ private Q_SLOTS: void testAmsDetection(); void testOutputDetection(); void testZeroModesHandling(); + void testModeGeneration(); }; static void verifyCleanup(MockGpu *mockGpu) @@ -158,5 +159,34 @@ void DrmTest::testZeroModesHandling() verifyCleanup(mockGpu.get()); } +void DrmTest::testModeGeneration() +{ + const auto mockGpu = std::make_unique(1, 5); + + const auto conn = std::make_shared(mockGpu.get()); + mockGpu->connectors.push_back(conn); + + const auto session = Session::create(Session::Type::Noop); + const auto backend = std::make_unique(session.get()); + const auto renderBackend = backend->createQPainterBackend(); + auto gpu = std::make_unique(backend.get(), "test", 1, 0); + + conn->modes.clear(); + conn->addMode(3840, 2160, 60); + QVERIFY(gpu->updateOutputs()); + QCOMPARE(gpu->drmOutputs().size(), 1); + + DrmOutput *const output = gpu->drmOutputs().front(); + QCOMPARE(output->modes().size(), 14); + for (const auto &mode : output->modes()) { + QVERIFY(mode->size().width() <= 3840); + QVERIFY(mode->size().height() <= 2160); + QVERIFY(mode->refreshRate() <= 60000); + } + + gpu.reset(); + verifyCleanup(mockGpu.get()); +} + QTEST_GUILESS_MAIN(DrmTest) #include "drmTest.moc"