feat: remove need for AppConfig from serverConnection
This commit is contained in:
@ -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)},
|
||||
|
||||
@ -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> deps
|
||||
QWidget *parent, IServerConfig &serverConfig, const config::ServerConfigDialogState &serverConfigDialogState,
|
||||
std::shared_ptr<Deps> deps
|
||||
)
|
||||
: m_pParent(parent),
|
||||
m_appConfig(appConfig),
|
||||
m_serverConfig(serverConfig),
|
||||
m_serverConfigDialogState(serverConfigDialogState),
|
||||
m_pDeps(deps)
|
||||
|
||||
@ -9,7 +9,6 @@
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#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> deps = std::make_shared<Deps>()
|
||||
);
|
||||
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<Deps> m_pDeps;
|
||||
|
||||
@ -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<DepsMock> m_pDeps = std::make_shared<NiceMock<DepsMock>>();
|
||||
NiceMock<AppConfigMock> m_appConfig;
|
||||
NiceMock<ServerConfigMock> 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);
|
||||
|
||||
Reference in New Issue
Block a user