From 787a48424ecd286d0f228517c1ff582cedec1a78 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Sat, 8 Mar 2025 11:41:14 -0500 Subject: [PATCH] feat: remove need for AppConfig from serverConnection --- src/apps/deskflow-gui/MainWindow.cpp | 2 +- src/lib/gui/core/ServerConnection.cpp | 5 ++--- src/lib/gui/core/ServerConnection.h | 5 +---- src/test/unittests/gui/core/ServerConnectionTests.cpp | 10 ++++------ 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/apps/deskflow-gui/MainWindow.cpp b/src/apps/deskflow-gui/MainWindow.cpp index 8f975465a..781a2b23d 100644 --- a/src/apps/deskflow-gui/MainWindow.cpp +++ b/src/apps/deskflow-gui/MainWindow.cpp @@ -66,7 +66,7 @@ MainWindow::MainWindow(ConfigScopes &configScopes, AppConfig &appConfig) m_appConfig(appConfig), m_serverConfig(appConfig, *this), m_coreProcess(appConfig, m_serverConfig), - m_serverConnection(this, appConfig, m_serverConfig, m_serverConfigDialogState), + m_serverConnection(this, m_serverConfig, m_serverConfigDialogState), m_clientConnection(this), m_tlsUtility(this), m_trayIcon{new QSystemTrayIcon(this)}, diff --git a/src/lib/gui/core/ServerConnection.cpp b/src/lib/gui/core/ServerConnection.cpp index fcb2d6167..a76f701bd 100644 --- a/src/lib/gui/core/ServerConnection.cpp +++ b/src/lib/gui/core/ServerConnection.cpp @@ -32,11 +32,10 @@ messages::NewClientPromptResult ServerConnection::Deps::showNewClientPrompt( // ServerConnection::ServerConnection( - QWidget *parent, IAppConfig &appConfig, IServerConfig &serverConfig, - const config::ServerConfigDialogState &serverConfigDialogState, std::shared_ptr deps + QWidget *parent, IServerConfig &serverConfig, const config::ServerConfigDialogState &serverConfigDialogState, + std::shared_ptr deps ) : m_pParent(parent), - m_appConfig(appConfig), m_serverConfig(serverConfig), m_serverConfigDialogState(serverConfigDialogState), m_pDeps(deps) diff --git a/src/lib/gui/core/ServerConnection.h b/src/lib/gui/core/ServerConnection.h index 8b8ee658f..36c89bb4b 100644 --- a/src/lib/gui/core/ServerConnection.h +++ b/src/lib/gui/core/ServerConnection.h @@ -9,7 +9,6 @@ #include #include -#include "gui/config/IAppConfig.h" #include "gui/config/IServerConfig.h" #include "gui/config/ServerConfigDialogState.h" #include "gui/messages.h" @@ -30,8 +29,7 @@ public: }; explicit ServerConnection( - QWidget *parent, IAppConfig &appConfig, IServerConfig &serverConfig, - const config::ServerConfigDialogState &serverConfigDialogState, + QWidget *parent, IServerConfig &serverConfig, const config::ServerConfigDialogState &serverConfigDialogState, std::shared_ptr deps = std::make_shared() ); void handleLogLine(const QString &logLine); @@ -44,7 +42,6 @@ private: void handleNewClient(const QString &clientName); QWidget *m_pParent; - IAppConfig &m_appConfig; IServerConfig &m_serverConfig; const config::ServerConfigDialogState &m_serverConfigDialogState; std::shared_ptr m_pDeps; diff --git a/src/test/unittests/gui/core/ServerConnectionTests.cpp b/src/test/unittests/gui/core/ServerConnectionTests.cpp index 8520b3041..c75a9b05f 100644 --- a/src/test/unittests/gui/core/ServerConnectionTests.cpp +++ b/src/test/unittests/gui/core/ServerConnectionTests.cpp @@ -7,7 +7,6 @@ #include "gui/config/ServerConfigDialogState.h" #include "gui/core/ServerConnection.h" -#include "shared/gui/mocks/AppConfigMock.h" #include "shared/gui/mocks/ServerConfigMock.h" #include "gmock/gmock.h" @@ -36,14 +35,13 @@ class ServerConnectionTests : public testing::Test { public: std::shared_ptr m_pDeps = std::make_shared>(); - NiceMock m_appConfig; NiceMock m_serverConfig; config::ServerConfigDialogState m_serverConfigDialogState; }; TEST_F(ServerConnectionTests, handleLogLine_newClient_shouldShowPrompt) { - ServerConnection serverConnection(nullptr, m_appConfig, m_serverConfig, m_serverConfigDialogState, m_pDeps); + ServerConnection serverConnection(nullptr, m_serverConfig, m_serverConfigDialogState, m_pDeps); QString clientName = "test client"; EXPECT_CALL(*m_pDeps, showNewClientPrompt(_, clientName, true)).Times(0); @@ -53,7 +51,7 @@ TEST_F(ServerConnectionTests, handleLogLine_newClient_shouldShowPrompt) TEST_F(ServerConnectionTests, handleLogLine_ignoredClient_shouldNotShowPrompt) { - ServerConnection serverConnection(nullptr, m_appConfig, m_serverConfig, m_serverConfigDialogState, m_pDeps); + ServerConnection serverConnection(nullptr, m_serverConfig, m_serverConfigDialogState, m_pDeps); ON_CALL(*m_pDeps, showNewClientPrompt(_, _, false)) .WillByDefault(testing::Return(messages::NewClientPromptResult::Ignore)); serverConnection.handleLogLine(R"(unrecognised client name "stub")"); @@ -65,7 +63,7 @@ TEST_F(ServerConnectionTests, handleLogLine_ignoredClient_shouldNotShowPrompt) TEST_F(ServerConnectionTests, handleLogLine_serverConfigFull_shouldNotShowPrompt) { - ServerConnection serverConnection(nullptr, m_appConfig, m_serverConfig, m_serverConfigDialogState, m_pDeps); + ServerConnection serverConnection(nullptr, m_serverConfig, m_serverConfigDialogState, m_pDeps); ON_CALL(m_serverConfig, isFull()).WillByDefault(testing::Return(true)); EXPECT_CALL(*m_pDeps, showNewClientPrompt(_, _, false)).Times(0); @@ -75,7 +73,7 @@ TEST_F(ServerConnectionTests, handleLogLine_serverConfigFull_shouldNotShowPrompt TEST_F(ServerConnectionTests, handleLogLine_screenExists_shouldNotShowPrompt) { - ServerConnection serverConnection(nullptr, m_appConfig, m_serverConfig, m_serverConfigDialogState, m_pDeps); + ServerConnection serverConnection(nullptr, m_serverConfig, m_serverConfigDialogState, m_pDeps); ON_CALL(m_serverConfig, screenExists(_)).WillByDefault(testing::Return(true)); EXPECT_CALL(*m_pDeps, showNewClientPrompt(_, _, false)).Times(0);