From c60f06545fc8162441991e82dbc2bd2e86d51585 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sun, 28 Jun 2026 20:15:52 -0400 Subject: [PATCH 1/7] Use lizardbyte-common test support in fixtures Switch the test fixture layer to `lizardbyte::common::testing::BaseTest` and link fixtures against `lizardbyte::test_support` instead of direct gtest helpers. This removes duplicated setup/teardown, argument parsing, output suppression, and env helper logic from local fixtures, and updates log-level env reads to use `lizardbyte::common::get_env`. The tests CMake setup now ensures lizardbyte-common test support is built and available, and the lizardbyte-common submodule is bumped to the required revision. --- .gitmodules | 4 - tests/CMakeLists.txt | 9 +- tests/fixtures/CMakeLists.txt | 2 +- tests/fixtures/fixtures.cpp | 90 +++----------------- tests/fixtures/include/fixtures/fixtures.h | 47 ++-------- tests/fixtures/include/fixtures/test_utils.h | 16 ---- tests/fixtures/test_utils.cpp | 18 ---- third-party/googletest | 1 - third-party/lizardbyte-common | 2 +- 9 files changed, 27 insertions(+), 162 deletions(-) delete mode 160000 third-party/googletest diff --git a/.gitmodules b/.gitmodules index e21742bb..67e53761 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,10 +2,6 @@ path = third-party/doxyconfig url = https://github.com/LizardByte/doxyconfig.git branch = master -[submodule "third-party/googletest"] - path = third-party/googletest - url = https://github.com/google/googletest.git - branch = v1.14.x [submodule "third-party/lizardbyte-common"] path = third-party/lizardbyte-common url = https://github.com/LizardByte/lizardbyte-common.git diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7d2f552a..ff3fe3ca 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -4,8 +4,15 @@ set(INSTALL_GTEST OFF) set(INSTALL_GMOCK OFF) include(GoogleTest) -add_subdirectory("${PROJECT_SOURCE_DIR}/third-party/googletest" "third-party/googletest") +add_subdirectory("${PROJECT_SOURCE_DIR}/third-party/lizardbyte-common/third-party/googletest" "third-party/googletest") +set(LIZARDBYTE_COMMON_BUILD_TEST_SUPPORT ON CACHE BOOL "Build lizardbyte-common GoogleTest support helpers" FORCE) +if(NOT TARGET lizardbyte::common) + add_subdirectory("${PROJECT_SOURCE_DIR}/third-party/lizardbyte-common" + "third-party/lizardbyte-common") +elseif(NOT TARGET lizardbyte::test_support) + message(FATAL_ERROR "libdisplaydevice tests require lizardbyte::test_support") +endif() if (WIN32) # For Windows: Prevent overriding the parent project's compiler/linker settings set(gtest_force_shared_crt ON CACHE BOOL "Always use msvcrt.dll" FORCE) # cmake-lint: disable=C0103 diff --git a/tests/fixtures/CMakeLists.txt b/tests/fixtures/CMakeLists.txt index 7ee2c995..88a3020c 100644 --- a/tests/fixtures/CMakeLists.txt +++ b/tests/fixtures/CMakeLists.txt @@ -18,8 +18,8 @@ include(Boost_DD) target_link_libraries(${MODULE} PUBLIC Boost::preprocessor + lizardbyte::test_support PRIVATE - gtest libdisplaydevice::common ) diff --git a/tests/fixtures/fixtures.cpp b/tests/fixtures/fixtures.cpp index b3ca5a9b..326203e3 100644 --- a/tests/fixtures/fixtures.cpp +++ b/tests/fixtures/fixtures.cpp @@ -1,19 +1,15 @@ // header include #include "fixtures/fixtures.h" -// system includes -#include +// lib includes +#include void BaseTest::SetUp() { - if (const auto skip_reason {skipTest()}; !skip_reason.empty()) { - m_test_skipped_at_setup = true; - GTEST_SKIP() << skip_reason; - } - - if (isOutputSuppressed()) { - // See https://stackoverflow.com/a/58369622/11214013 - m_sbuf = std::cout.rdbuf(); // save cout buffer (std::cout) - std::cout.rdbuf(m_cout_buffer.rdbuf()); // redirect cout to buffer (std::cout) + m_test_skipped_at_setup = false; + ::lizardbyte::common::testing::BaseTest::SetUp(); + m_test_skipped_at_setup = ::testing::Test::IsSkipped(); + if (m_test_skipped_at_setup) { + return; } // Set the default log level, before the test starts. Will default to verbose in case nothing was specified. @@ -21,74 +17,12 @@ void BaseTest::SetUp() { } void BaseTest::TearDown() { - if (m_test_skipped_at_setup) { - // We are not using the IsSkipped() state here. Here we are skipping - // teardown, because we have skipped the setup entirely, but during normal - // skips we still want to do teardown. - return; + if (!m_test_skipped_at_setup) { + // reset the callback to avoid potential leaks + display_device::Logger::get().setCustomCallback(nullptr); } - // reset the callback to avoid potential leaks - display_device::Logger::get().setCustomCallback(nullptr); - - // Restore cout buffer and print the suppressed output out in case we have failed :/ - if (isOutputSuppressed()) { - std::cout.rdbuf(m_sbuf); - m_sbuf = nullptr; - - const auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); - if (test_info && test_info->result()->Failed()) { - std::cout << std::endl - << "Test failed: " << test_info->name() << std::endl - << std::endl - << "Captured cout:" << std::endl - << m_cout_buffer.str() << std::endl; - } - } -} - -const std::vector &BaseTest::getArgs() const { - static const auto args {::testing::internal::GetArgvs()}; - return args; -} - -std::optional BaseTest::getArgWithMatchingPattern(const std::string &pattern, bool remove_match) const { - if (const auto &args {getArgs()}; !args.empty()) { - const std::regex re_pattern {pattern}; - - // We are skipping the first arg which is always binary name/path. - for (auto it {std::next(std::begin(args))}; it != std::end(args); ++it) { - if (std::smatch match; std::regex_search(*it, match, re_pattern)) { - return remove_match ? std::regex_replace(*it, re_pattern, "") : *it; - } - } - } - - return std::nullopt; -} - -bool BaseTest::isOutputSuppressed() const { - return true; -} - -bool BaseTest::isSystemTest() const { - return false; -} - -std::string BaseTest::skipTest() const { - if (isSystemTest()) { - const static bool is_system_test_skippable { - []() { - const auto value {getEnv("SKIP_SYSTEM_TESTS")}; - return value == "1"; - }() - }; - - if (is_system_test_skippable) { - return "Skipping, this system test is disabled via SKIP_SYSTEM_TESTS=1 env."; - } - } - return {}; + ::lizardbyte::common::testing::BaseTest::TearDown(); } std::optional BaseTest::getDefaultLogLevel() const { @@ -96,7 +30,7 @@ std::optional BaseTest::getDefaultLogLevel() c []() -> std::optional { using enum display_device::Logger::LogLevel; - const auto value {getEnv("LOG_LEVEL")}; + const auto value {lizardbyte::common::get_env("LOG_LEVEL")}; if (value == "verbose") { return verbose; } diff --git a/tests/fixtures/include/fixtures/fixtures.h b/tests/fixtures/include/fixtures/fixtures.h index 1c309860..28fcd8ff 100644 --- a/tests/fixtures/include/fixtures/fixtures.h +++ b/tests/fixtures/include/fixtures/fixtures.h @@ -6,7 +6,10 @@ #include #include #include -#include + +#define LIZARDBYTE_COMMON_TESTING_KEEP_GTEST_TEST +#define LIZARDBYTE_COMMON_TESTING_NO_GLOBAL_ALIASES +#include // local includes #include "display_device/logging.h" @@ -39,7 +42,7 @@ * * This class provides a base test fixture for all tests. */ -class BaseTest: public ::testing::Test { +class BaseTest: public ::lizardbyte::common::testing::BaseTest { protected: ~BaseTest() override = default; @@ -47,40 +50,6 @@ class BaseTest: public ::testing::Test { void TearDown() override; - /** - * @brief Get available command line arguments. - * @return Command line args from GTest. - */ - [[nodiscard]] virtual const std::vector &getArgs() const; - - /** - * @brief Get the command line argument that matches the pattern. - * @param pattern Pattern to look for. - * @param remove_match Specify if the matched pattern should be removed before returning argument. - * @return Matching command line argument or null optional if nothing matched. - */ - [[nodiscard]] virtual std::optional getArgWithMatchingPattern(const std::string &pattern, bool remove_match) const; - - /** - * @brief Check if the test output is to be redirected and printed out only if test fails. - * @return True if output is to be suppressed, false otherwise. - * @note It is useful for suppressing noise in automatic tests, but not so much in manual ones. - */ - [[nodiscard]] virtual bool isOutputSuppressed() const; - - /** - * @brief Check if the test interacts/modifies with the system settings. - * @returns True if it does, false otherwise. - * @note By setting SKIP_SYSTEM_TESTS=1 env, these tests will be skipped (useful during development). - */ - [[nodiscard]] virtual bool isSystemTest() const; - - /** - * @brief Skip the test by specifying the reason. - * @returns A non-empty string (reason) if test needs to be skipped, empty string otherwise. - */ - [[nodiscard]] virtual std::string skipTest() const; - /** * @brief Get the default log level for the test base. * @returns A log level set in the env OR null optional if fallback should be used (verbose). @@ -88,12 +57,6 @@ class BaseTest: public ::testing::Test { */ [[nodiscard]] virtual std::optional getDefaultLogLevel() const; - [[nodiscard]] std::stringstream &coutBuffer() { - return m_cout_buffer; - } - private: - std::stringstream m_cout_buffer; /**< Stores the cout in case the output is suppressed. */ - std::streambuf *m_sbuf {nullptr}; /**< Stores the handle to the original cout stream. */ bool m_test_skipped_at_setup {false}; /**< Indicates whether the SetUp method was skipped. */ }; diff --git a/tests/fixtures/include/fixtures/test_utils.h b/tests/fixtures/include/fixtures/test_utils.h index 6a14f7bd..fe8826ad 100644 --- a/tests/fixtures/include/fixtures/test_utils.h +++ b/tests/fixtures/include/fixtures/test_utils.h @@ -1,7 +1,6 @@ #pragma once // system includes -#include #include #include @@ -22,18 +21,3 @@ namespace ut_consts { * @return True if string matches the regex, false otherwise. */ bool testRegex(const std::string &test_pattern, const std::string ®ex_pattern); - -/** - * @brief Set an environment variable. - * @param name Name of the environment variable. - * @param value Value of the environment variable. - * @return 0 on success, non-zero error code on failure. - */ -int setEnv(const std::string &name, const std::string &value); - -/** - * @brief Get an environment variable. - * @param name Name of the environment variable. - * @return String value of the variable or an empty optional otherwise. - */ -std::optional getEnv(const std::string &name); diff --git a/tests/fixtures/test_utils.cpp b/tests/fixtures/test_utils.cpp index 6d2ec80f..b7ccf762 100644 --- a/tests/fixtures/test_utils.cpp +++ b/tests/fixtures/test_utils.cpp @@ -1,9 +1,6 @@ // header include #include "fixtures/test_utils.h" -// system includes -#include - // system includes #include #include @@ -51,18 +48,3 @@ bool testRegex(const std::string &input, const std::string &pattern) { } return true; } - -int setEnv(const std::string &name, const std::string &value) { -#ifdef _WIN32 - return _putenv_s(name.c_str(), value.c_str()); -#else - return setenv(name.c_str(), value.c_str(), 1); -#endif -} - -std::optional getEnv(const std::string &name) { - if (const auto value {std::getenv(name.c_str())}; value) { - return std::string {value}; - } - return std::nullopt; -} diff --git a/third-party/googletest b/third-party/googletest deleted file mode 160000 index f8d7d77c..00000000 --- a/third-party/googletest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f8d7d77c06936315286eb55f8de22cd23c188571 diff --git a/third-party/lizardbyte-common b/third-party/lizardbyte-common index 8d7dcc97..0fcde420 160000 --- a/third-party/lizardbyte-common +++ b/third-party/lizardbyte-common @@ -1 +1 @@ -Subproject commit 8d7dcc97d0795e4eb2efdb50a86f83060ed47934 +Subproject commit 0fcde420419c77fdde04ffb04ceda0b560bd1cfc From 1224f181b2ac18dbe0904f0fe97f18bb6c1adcc1 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sun, 28 Jun 2026 23:44:32 -0400 Subject: [PATCH 2/7] Update lizardbyte-common submodule Advance the `third-party/lizardbyte-common` submodule from `0fcde42` to `d219f38` to pull in the latest upstream common library changes. --- third-party/lizardbyte-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third-party/lizardbyte-common b/third-party/lizardbyte-common index 0fcde420..d219f380 160000 --- a/third-party/lizardbyte-common +++ b/third-party/lizardbyte-common @@ -1 +1 @@ -Subproject commit 0fcde420419c77fdde04ffb04ceda0b560bd1cfc +Subproject commit d219f38090db20119906c80860833592a6be669a From 3eaf47365b8efc940f202bdf14a7dc28cd4f8bf7 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Mon, 29 Jun 2026 10:21:56 -0400 Subject: [PATCH 3/7] Bump lizardbyte-common submodule Update `third-party/lizardbyte-common` to commit `60bf936` from `d219f38` to pull in the latest upstream changes. --- third-party/lizardbyte-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third-party/lizardbyte-common b/third-party/lizardbyte-common index d219f380..60bf936e 160000 --- a/third-party/lizardbyte-common +++ b/third-party/lizardbyte-common @@ -1 +1 @@ -Subproject commit d219f38090db20119906c80860833592a6be669a +Subproject commit 60bf936e134359c65c8a044369db227f976947e5 From 52e96641ee7dc01eb891248ad3306a4051e6f10c Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Mon, 29 Jun 2026 14:02:55 -0400 Subject: [PATCH 4/7] Bump lizardbyte-common submodule Update `third-party/lizardbyte-common` to commit `3f29834c942d71d626f2daf67323fc61426bf524`. --- third-party/lizardbyte-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third-party/lizardbyte-common b/third-party/lizardbyte-common index 60bf936e..3f29834c 160000 --- a/third-party/lizardbyte-common +++ b/third-party/lizardbyte-common @@ -1 +1 @@ -Subproject commit 60bf936e134359c65c8a044369db227f976947e5 +Subproject commit 3f29834c942d71d626f2daf67323fc61426bf524 From f01994f1db5e1c4013750ffad6a7a1285b6684f2 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Mon, 29 Jun 2026 20:54:09 -0400 Subject: [PATCH 5/7] Refresh README branding and add docs run config Revamps the README with centered branding, richer status badges, and cleaner section headers/content updates (including current platform support). Also adds a JetBrains CMake run configuration to build and open generated documentation in the browser. --- .run/docs.run.xml | 7 +++++++ README.md | 32 +++++++++++++++++++++++--------- 2 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 .run/docs.run.xml diff --git a/.run/docs.run.xml b/.run/docs.run.xml new file mode 100644 index 00000000..859fba01 --- /dev/null +++ b/.run/docs.run.xml @@ -0,0 +1,7 @@ + + + + + + diff --git a/README.md b/README.md index 92c0d4dd..7af94137 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,34 @@ -# Overview +
+ LizardByte icon +

libdisplaydevice

+

C++ library to modify display devices.

+
+ +
+ GitHub stars + GitHub Workflow Status (CI) + Read the Docs + Codecov + SonarCloud +
-[![GitHub Workflow Status (CI)](https://img.shields.io/github/actions/workflow/status/lizardbyte/libdisplaydevice/ci.yml.svg?branch=master&label=CI%20build&logo=github&style=for-the-badge)](https://github.com/LizardByte/libdisplaydevice/actions/workflows/ci.yml?query=branch%3Amaster) -[![Codecov](https://img.shields.io/codecov/c/gh/LizardByte/libdisplaydevice?token=goyvmDl6J5&style=for-the-badge&logo=codecov&label=codecov)](https://codecov.io/gh/LizardByte/libdisplaydevice) -[![GitHub stars](https://img.shields.io/github/stars/lizardbyte/libdisplaydevice.svg?logo=github&style=for-the-badge)](https://github.com/LizardByte/libdisplaydevice) +# Overview -## About +## â„šī¸ About LizardByte has the full documentation hosted on [Read the Docs](https://libdisplaydevice.readthedocs.io/). -libdisplaydevice is a WIP library that provides a common interface for interacting with display devices. +libdisplaydevice is a library that provides a common interface for interacting with display devices. It is intended to be used by applications that need to interact with displays, such as screen capture software, remote desktop software, and video players. -Initial support is planned for Windows, but could be expanded to other platforms in the future. +Windows and macOS are currently supported. Support for Linux is planned for the future. -## Build +## đŸ› ī¸ Build ### Clone @@ -76,7 +90,7 @@ ninja -C build ./build/tests/test_libdisplaydevice ``` -## Support +## ❓ Support Our support methods are listed in our [LizardByte Docs](https://lizardbyte.readthedocs.io/latest/about/support.html). From 9f390efc890a556c9a79e627dd1385b7dd2d4460 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Tue, 30 Jun 2026 09:53:25 -0400 Subject: [PATCH 6/7] Remove docs badge and bump common submodule Drops the Read the Docs badge from the README header and updates `third-party/lizardbyte-common` to commit `49aa8c6` to pull in the latest shared common changes. --- README.md | 1 - third-party/lizardbyte-common | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 7af94137..2243fc1a 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,6 @@
GitHub stars GitHub Workflow Status (CI) - Read the Docs Codecov SonarCloud
diff --git a/third-party/lizardbyte-common b/third-party/lizardbyte-common index 3f29834c..49aa8c60 160000 --- a/third-party/lizardbyte-common +++ b/third-party/lizardbyte-common @@ -1 +1 @@ -Subproject commit 3f29834c942d71d626f2daf67323fc61426bf524 +Subproject commit 49aa8c6040487a83a57ee454dae30a4c93275f5b From 297dbc33ca17fcaabcd79982cf6294de0963f3c5 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Tue, 30 Jun 2026 17:55:20 -0400 Subject: [PATCH 7/7] Bump lizardbyte-common submodule Update `third-party/lizardbyte-common` from `49aa8c6` to `06cd442` to pull in the latest upstream changes in the shared common dependency. --- third-party/lizardbyte-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third-party/lizardbyte-common b/third-party/lizardbyte-common index 49aa8c60..06cd442b 160000 --- a/third-party/lizardbyte-common +++ b/third-party/lizardbyte-common @@ -1 +1 @@ -Subproject commit 49aa8c6040487a83a57ee454dae30a4c93275f5b +Subproject commit 06cd442b808f02f1674f3192a84d25b9a503c482