From 98250e9c32c5b9b940da2fb0a32d8139bbc68157 Mon Sep 17 00:00:00 2001 From: Alan Griffiths Date: Thu, 31 Aug 2023 12:05:13 +0100 Subject: [PATCH] Fix the signature of drmModeCrtcSetGamma --- tests/include/mir/test/doubles/mock_drm.h | 2 +- tests/mir_test_doubles/mock_drm.cpp | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/tests/include/mir/test/doubles/mock_drm.h b/tests/include/mir/test/doubles/mock_drm.h index aeba8c7d05d..d3c44f30c20 100644 --- a/tests/include/mir/test/doubles/mock_drm.h +++ b/tests/include/mir/test/doubles/mock_drm.h @@ -155,7 +155,7 @@ class MockDRM MOCK_METHOD6(drmModeCrtcGetGamma, int(int fd, uint32_t crtc_id, uint32_t size, uint16_t* red, uint16_t* green, uint16_t* blue)); MOCK_METHOD6(drmModeCrtcSetGamma, int(int fd, uint32_t crtc_id, uint32_t size, - uint16_t* red, uint16_t* green, uint16_t* blue)); + uint16_t const* red, uint16_t const* green, uint16_t const* blue)); MOCK_METHOD1(drmGetVersion, drmVersionPtr(int)); MOCK_METHOD1(drmFreeVersion, void(drmVersionPtr)); diff --git a/tests/mir_test_doubles/mock_drm.cpp b/tests/mir_test_doubles/mock_drm.cpp index d3d5840b7a0..bd51466cbac 100644 --- a/tests/mir_test_doubles/mock_drm.cpp +++ b/tests/mir_test_doubles/mock_drm.cpp @@ -489,6 +489,24 @@ testing::Matcher mtd::IsFdOfDevice(char const* device) return ::testing::MakeMatcher(new mtd::MockDRM::IsFdOfDeviceMatcher(device)); } +// The signature of drmModeCrtcSetGamma() changes from passing the gamma as `uint16_t*` to `uint16_t const*` +// We need to provide a definition that matches +namespace +{ +template +struct Decode_drmModeCrtcSetGamma_signature; + +template +struct Decode_drmModeCrtcSetGamma_signature +{ + using gamma_t = Arg; +}; +using gamma_t = Decode_drmModeCrtcSetGamma_signature::gamma_t; +} + +// Ensure we get a compile error if the definition doesn't match the declaration (instead of providing an overload) +extern "C" +{ int drmOpen(const char *name, const char *busid) { return global_mock->drmOpen(name, busid); @@ -548,8 +566,7 @@ int drmModeCrtcGetGamma(int fd, uint32_t crtc_id, uint32_t size, return global_mock->drmModeCrtcGetGamma(fd, crtc_id, size, red, green, blue); } -int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size, - uint16_t* red, uint16_t* green, uint16_t* blue) +int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size, gamma_t red, gamma_t green, gamma_t blue) { return global_mock->drmModeCrtcSetGamma(fd, crtc_id, size, red, green, blue); } @@ -751,3 +768,4 @@ int drmCheckModesettingSupported(char const* busid) { return global_mock->drmCheckModesettingSupported(busid); } +}