From 33edb6ce01f115c8e6643cdbd6f9c19685cebe22 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Fri, 9 May 2025 22:49:41 -0400 Subject: [PATCH] refactor: simplify wayland warnings remove waylandwarnigns dialog test --- src/lib/gui/core/WaylandWarnings.cpp | 15 +--- src/lib/gui/core/WaylandWarnings.h | 12 +-- .../gui/core/WaylandWarningsTests.cpp | 80 ------------------- 3 files changed, 2 insertions(+), 105 deletions(-) delete mode 100644 src/unittests/legacytests/legacytests/gui/core/WaylandWarningsTests.cpp diff --git a/src/lib/gui/core/WaylandWarnings.cpp b/src/lib/gui/core/WaylandWarnings.cpp index a7c6c3c4c..3e106414c 100644 --- a/src/lib/gui/core/WaylandWarnings.cpp +++ b/src/lib/gui/core/WaylandWarnings.cpp @@ -13,19 +13,6 @@ using namespace deskflow::platform; namespace deskflow::gui::core { -// -// WaylandWarnings::Deps -// - -void WaylandWarnings::Deps::showWaylandLibraryError(QWidget *parent) -{ - messages::showWaylandLibraryError(parent); -} - -// -// WaylandWarnings -// - void WaylandWarnings::showOnce(QWidget *parent, bool hasEi, bool hasPortal, bool hasPortalInputCapture) { const auto mode = Settings::value(Settings::Core::CoreMode).value(); @@ -34,7 +21,7 @@ void WaylandWarnings::showOnce(QWidget *parent, bool hasEi, bool hasPortal, bool if (!hasEi || !hasPortal || portalIcProblem) { if (!m_errorShown) { m_errorShown = true; - m_pDeps->showWaylandLibraryError(parent); + messages::showWaylandLibraryError(parent); } else { qWarning("missing required wayland lib(s) or feature"); } diff --git a/src/lib/gui/core/WaylandWarnings.h b/src/lib/gui/core/WaylandWarnings.h index a0d821b28..9aa5ce982 100644 --- a/src/lib/gui/core/WaylandWarnings.h +++ b/src/lib/gui/core/WaylandWarnings.h @@ -7,7 +7,6 @@ #pragma once #include -#include #include "platform/Wayland.h" @@ -16,15 +15,7 @@ namespace deskflow::gui::core { class WaylandWarnings { public: - struct Deps - { - virtual ~Deps() = default; - virtual void showWaylandLibraryError(QWidget *parent); - }; - - explicit WaylandWarnings(std::shared_ptr deps = std::make_shared()) : m_pDeps(deps) - { - } + explicit WaylandWarnings() = default; void showOnce( QWidget *parent, bool hasEi = platform::kHasEi, bool hasPortal = platform::kHasPortal, @@ -33,7 +24,6 @@ public: private: bool m_errorShown{false}; - std::shared_ptr m_pDeps; }; } // namespace deskflow::gui::core diff --git a/src/unittests/legacytests/legacytests/gui/core/WaylandWarningsTests.cpp b/src/unittests/legacytests/legacytests/gui/core/WaylandWarningsTests.cpp deleted file mode 100644 index 5c7961e27..000000000 --- a/src/unittests/legacytests/legacytests/gui/core/WaylandWarningsTests.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2024 Symless Ltd. - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#include "gui/core/WaylandWarnings.h" - -#include "gui/core/CoreProcess.h" - -#include -#include - -using namespace deskflow::gui; -using namespace deskflow::gui::core; - -namespace { -struct MockDeps : public WaylandWarnings::Deps -{ - MOCK_METHOD(void, showWaylandLibraryError, (QWidget *), (override)); -}; - -} // namespace - -TEST(WaylandWarningsTests, showOnce_serverNoEi_showLibraryError) -{ - const auto deps = std::make_shared(); - const bool hasEi = false; - const bool hasPortal = false; - const bool hasPortalIC = false; - WaylandWarnings waylandWarnings(deps); - Settings::setValue(Settings::Core::CoreMode, Settings::CoreMode::Server); - - EXPECT_CALL(*deps, showWaylandLibraryError(nullptr)).Times(1); - - waylandWarnings.showOnce(nullptr, hasEi, hasPortal, hasPortalIC); -} - -TEST(WaylandWarningsTests, showOnce_serverNoPortal_showLibraryError) -{ - const auto deps = std::make_shared(); - const bool hasEi = true; - const bool hasPortal = false; - const bool hasPortalIC = false; - WaylandWarnings waylandWarnings(deps); - Settings::setValue(Settings::Core::CoreMode, Settings::CoreMode::Server); - - EXPECT_CALL(*deps, showWaylandLibraryError(nullptr)).Times(1); - - waylandWarnings.showOnce(nullptr, hasEi, hasPortal, hasPortalIC); -} - -TEST(WaylandWarningsTests, showOnce_serverNoPortalIc_showLibraryError) -{ - const auto deps = std::make_shared(); - const bool hasEi = true; - const bool hasPortal = true; - const bool hasPortalIC = false; - WaylandWarnings waylandWarnings(deps); - Settings::setValue(Settings::Core::CoreMode, Settings::CoreMode::Server); - - EXPECT_CALL(*deps, showWaylandLibraryError(nullptr)).Times(1); - - waylandWarnings.showOnce(nullptr, hasEi, hasPortal, hasPortalIC); -} - -TEST(WaylandWarningsTests, showOnce_failureCalledTwice_messageOnlyShownOnce) -{ - const auto deps = std::make_shared(); - const bool hasEi = false; - const bool hasPortal = false; - const bool hasPortalIC = false; - WaylandWarnings waylandWarnings(deps); - Settings::setValue(Settings::Core::CoreMode, Settings::CoreMode::Server); - - EXPECT_CALL(*deps, showWaylandLibraryError(nullptr)).Times(1); - - waylandWarnings.showOnce(nullptr, hasEi, hasPortal, hasPortalIC); - waylandWarnings.showOnce(nullptr, hasEi, hasPortal, hasPortalIC); -}