feat: remove need for AppConfig in Client Connection
This commit is contained in:
parent
dc9e104f8c
commit
43eab1f04c
4 changed files with 11 additions and 20 deletions
|
|
@ -67,7 +67,7 @@ MainWindow::MainWindow(ConfigScopes &configScopes, AppConfig &appConfig)
|
|||
m_serverConfig(appConfig, *this),
|
||||
m_coreProcess(appConfig, m_serverConfig),
|
||||
m_serverConnection(this, appConfig, m_serverConfig, m_serverConfigDialogState),
|
||||
m_clientConnection(this, appConfig),
|
||||
m_clientConnection(this),
|
||||
m_tlsUtility(this),
|
||||
m_trayIcon{new QSystemTrayIcon(this)},
|
||||
m_guiDupeChecker{new QLocalServer(this)},
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "ClientConnection.h"
|
||||
|
||||
#include "common/settings.h"
|
||||
#include "common/Settings.h"
|
||||
#include "messages.h"
|
||||
|
||||
#include <QHostAddress>
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "gui/config/IAppConfig.h"
|
||||
|
||||
#include "gui/messages.h"
|
||||
|
||||
#include <QObject>
|
||||
|
|
@ -30,11 +28,8 @@ public:
|
|||
virtual void showError(QWidget *parent, messages::ClientError error, const QString &address) const;
|
||||
};
|
||||
|
||||
explicit ClientConnection(
|
||||
QWidget *parent, IAppConfig &appConfig, std::shared_ptr<Deps> deps = std::make_shared<Deps>()
|
||||
)
|
||||
explicit ClientConnection(QWidget *parent, std::shared_ptr<Deps> deps = std::make_shared<Deps>())
|
||||
: m_pParent(parent),
|
||||
m_appConfig(appConfig),
|
||||
m_deps(deps)
|
||||
{
|
||||
}
|
||||
|
|
@ -52,7 +47,6 @@ private:
|
|||
void showMessage(const QString &logLine);
|
||||
|
||||
QWidget *m_pParent;
|
||||
IAppConfig &m_appConfig;
|
||||
std::shared_ptr<Deps> m_deps;
|
||||
bool m_showMessage = true;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,11 +4,9 @@
|
|||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
*/
|
||||
|
||||
#include "common/settings.h"
|
||||
#include "common/Settings.h"
|
||||
#include "gui/core/ClientConnection.h"
|
||||
|
||||
#include "shared/gui/mocks/AppConfigMock.h"
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
@ -39,7 +37,6 @@ public:
|
|||
}
|
||||
|
||||
std::shared_ptr<DepsMock> m_pDeps = std::make_shared<NiceMock<DepsMock>>();
|
||||
NiceMock<AppConfigMock> m_appConfig;
|
||||
|
||||
private:
|
||||
const QString stub = "stub";
|
||||
|
|
@ -47,7 +44,7 @@ private:
|
|||
|
||||
TEST_F(ClientConnectionTests, handleLogLine_alreadyConnected_showError)
|
||||
{
|
||||
ClientConnection clientConnection(nullptr, m_appConfig, m_pDeps);
|
||||
ClientConnection clientConnection(nullptr, m_pDeps);
|
||||
|
||||
const QString serverName = "test server";
|
||||
Settings::setValue(Settings::Client::RemoteHost, serverName);
|
||||
|
|
@ -62,7 +59,7 @@ TEST_F(ClientConnectionTests, handleLogLine_alreadyConnected_showError)
|
|||
|
||||
TEST_F(ClientConnectionTests, handleLogLine_withHostname_showError)
|
||||
{
|
||||
ClientConnection clientConnection(nullptr, m_appConfig, m_pDeps);
|
||||
ClientConnection clientConnection(nullptr, m_pDeps);
|
||||
|
||||
const QString serverName = "test hostname";
|
||||
Settings::setValue(Settings::Client::RemoteHost, serverName);
|
||||
|
|
@ -74,7 +71,7 @@ TEST_F(ClientConnectionTests, handleLogLine_withHostname_showError)
|
|||
|
||||
TEST_F(ClientConnectionTests, handleLogLine_withIpAddress_showError)
|
||||
{
|
||||
ClientConnection clientConnection(nullptr, m_appConfig, m_pDeps);
|
||||
ClientConnection clientConnection(nullptr, m_pDeps);
|
||||
|
||||
const QString serverName = "1.1.1.1";
|
||||
Settings::setValue(Settings::Client::RemoteHost, serverName);
|
||||
|
|
@ -86,7 +83,7 @@ TEST_F(ClientConnectionTests, handleLogLine_withIpAddress_showError)
|
|||
|
||||
TEST_F(ClientConnectionTests, handleLogLine_messageShown_shouldNotShowAgain)
|
||||
{
|
||||
ClientConnection clientConnection(nullptr, m_appConfig, m_pDeps);
|
||||
ClientConnection clientConnection(nullptr, m_pDeps);
|
||||
|
||||
clientConnection.handleLogLine("failed to connect to server");
|
||||
|
||||
|
|
@ -97,7 +94,7 @@ TEST_F(ClientConnectionTests, handleLogLine_messageShown_shouldNotShowAgain)
|
|||
|
||||
TEST_F(ClientConnectionTests, handleLogLine_serverRefusedClient_shouldNotShowError)
|
||||
{
|
||||
ClientConnection clientConnection(nullptr, m_appConfig, m_pDeps);
|
||||
ClientConnection clientConnection(nullptr, m_pDeps);
|
||||
|
||||
EXPECT_CALL(*m_pDeps, showError(_, _, _)).Times(0);
|
||||
|
||||
|
|
@ -109,7 +106,7 @@ TEST_F(ClientConnectionTests, handleLogLine_serverRefusedClient_shouldNotShowErr
|
|||
|
||||
TEST_F(ClientConnectionTests, handleLogLine_connected_shouldPreventFutureError)
|
||||
{
|
||||
ClientConnection clientConnection(nullptr, m_appConfig, m_pDeps);
|
||||
ClientConnection clientConnection(nullptr, m_pDeps);
|
||||
clientConnection.handleLogLine("connected to server");
|
||||
|
||||
EXPECT_CALL(*m_pDeps, showError(_, _, _)).Times(0);
|
||||
|
|
@ -119,7 +116,7 @@ TEST_F(ClientConnectionTests, handleLogLine_connected_shouldPreventFutureError)
|
|||
|
||||
TEST_F(ClientConnectionTests, handleLogLine_otherMessage_shouldNotShowError)
|
||||
{
|
||||
ClientConnection clientConnection(nullptr, m_appConfig, m_pDeps);
|
||||
ClientConnection clientConnection(nullptr, m_pDeps);
|
||||
|
||||
EXPECT_CALL(*m_pDeps, showError(_, _, _)).Times(0);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue