refactor: move Coremode control to Settings

newKey core/coreMode <= General/serverGroupEnabled , Genaral/clientGroupEnabled
remove core mode items from appconfig
This commit is contained in:
sithlord48 2025-03-09 22:50:44 -04:00 committed by Nick Bolton
parent 6362948e15
commit 8606dc8618
14 changed files with 90 additions and 112 deletions

View file

@ -56,7 +56,6 @@
using namespace deskflow::gui; using namespace deskflow::gui;
using CoreMode = CoreProcess::Mode;
using CoreConnectionState = CoreProcess::ConnectionState; using CoreConnectionState = CoreProcess::ConnectionState;
using CoreProcessState = CoreProcess::ProcessState; using CoreProcessState = CoreProcess::ProcessState;
@ -233,11 +232,13 @@ void MainWindow::setupControls()
ui->serverOptions->setVisible(false); ui->serverOptions->setVisible(false);
ui->clientOptions->setVisible(false); ui->clientOptions->setVisible(false);
ui->rbModeClient->setChecked(m_appConfig.clientGroupChecked());
ui->rbModeServer->setChecked(m_appConfig.serverGroupChecked());
if (m_appConfig.clientGroupChecked() || m_appConfig.serverGroupChecked()) const auto coreMode = Settings::value(Settings::Core::CoreMode).value<Settings::CoreMode>();
updateModeControls(m_appConfig.serverGroupChecked()); ui->rbModeClient->setChecked(coreMode == Settings::CoreMode::Client);
ui->rbModeServer->setChecked(coreMode == Settings::CoreMode::Server);
if (coreMode != Settings::CoreMode::None)
updateModeControls(coreMode == Settings::CoreMode::Server);
ui->lineEditName->setValidator(new QRegularExpressionValidator(m_nameRegEx, this)); ui->lineEditName->setValidator(new QRegularExpressionValidator(m_nameRegEx, this));
ui->lineEditName->setVisible(false); ui->lineEditName->setVisible(false);
@ -565,10 +566,10 @@ void MainWindow::coreModeToggled()
const auto mode = serverMode ? QStringLiteral("server enabled") : QStringLiteral("client enabled"); const auto mode = serverMode ? QStringLiteral("server enabled") : QStringLiteral("client enabled");
qDebug() << mode; qDebug() << mode;
m_appConfig.setServerGroupChecked(serverMode); const auto coreMode = serverMode ? Settings::CoreMode::Server : Settings::CoreMode::Client;
m_appConfig.setClientGroupChecked(!serverMode); Settings::setValue(Settings::Core::CoreMode, coreMode);
m_configScopes.save();
m_configScopes.save();
updateModeControls(serverMode); updateModeControls(serverMode);
} }
@ -579,7 +580,7 @@ void MainWindow::updateModeControls(bool serverMode)
ui->lblNoMode->setVisible(false); ui->lblNoMode->setVisible(false);
ui->btnToggleCore->setEnabled(true); ui->btnToggleCore->setEnabled(true);
m_actionStartCore->setEnabled(true); m_actionStartCore->setEnabled(true);
auto expectedCoreMode = serverMode ? CoreProcess::Mode::Server : CoreProcess::Mode::Client; auto expectedCoreMode = serverMode ? Settings::CoreMode::Server : Settings::CoreMode::Client;
if (m_coreProcess.isStarted() && m_coreProcess.mode() != expectedCoreMode) if (m_coreProcess.isStarted() && m_coreProcess.mode() != expectedCoreMode)
m_coreProcess.stop(); m_coreProcess.stop();
m_coreProcess.setMode(expectedCoreMode); m_coreProcess.setMode(expectedCoreMode);
@ -652,7 +653,7 @@ void MainWindow::open()
void MainWindow::coreProcessStarting() void MainWindow::coreProcessStarting()
{ {
if (deskflow::platform::isWayland()) { if (deskflow::platform::isWayland()) {
m_waylandWarnings.showOnce(this, m_coreProcess.mode()); m_waylandWarnings.showOnce(this);
} }
saveSettings(); saveSettings();
} }
@ -715,17 +716,21 @@ void MainWindow::applyConfig()
updateLocalFingerprint(); updateLocalFingerprint();
setIcon(); setIcon();
if (!m_appConfig.serverGroupChecked() && !m_appConfig.clientGroupChecked()) const auto coreMode = Settings::value(Settings::Core::CoreMode).value<Settings::CoreMode>();
if (coreMode == Settings::CoreMode::None)
return; return;
updateModeControls(m_appConfig.serverGroupChecked()); updateModeControls(coreMode == Settings::CoreMode::Server);
} }
void MainWindow::saveSettings() void MainWindow::saveSettings()
{ {
m_appConfig.setServerGroupChecked(ui->rbModeServer->isChecked()); if (ui->rbModeClient->isChecked()) {
m_appConfig.setClientGroupChecked(ui->rbModeClient->isChecked()); Settings::setValue(Settings::Core::CoreMode, Settings::CoreMode::Client);
} else if (ui->rbModeServer->isChecked()) {
Settings::setValue(Settings::Core::CoreMode, Settings::CoreMode::Server);
}
Settings::setValue(Settings::Client::RemoteHost, ui->lineHostname->text()); Settings::setValue(Settings::Client::RemoteHost, ui->lineHostname->text());
m_configScopes.save(); m_configScopes.save();
} }

View file

@ -59,7 +59,7 @@ class DaemonIpcClient;
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
using CoreMode = deskflow::gui::CoreProcess::Mode; using CoreMode = Settings::CoreMode;
using CoreProcess = deskflow::gui::CoreProcess; using CoreProcess = deskflow::gui::CoreProcess;
Q_OBJECT Q_OBJECT

View file

@ -244,7 +244,8 @@ void SettingsDialog::updateTlsControls()
void SettingsDialog::updateTlsControlsEnabled() void SettingsDialog::updateTlsControlsEnabled()
{ {
const auto writable = m_appConfig.isActiveScopeWritable(); const auto writable = m_appConfig.isActiveScopeWritable();
const auto clientMode = m_appConfig.clientGroupChecked(); const auto clientMode =
Settings::value(Settings::Core::CoreMode).value<Settings::CoreMode>() == Settings::CoreMode::Client;
const auto tlsChecked = ui->groupSecurity->isChecked(); const auto tlsChecked = ui->groupSecurity->isChecked();
auto enabled = writable && tlsChecked && !clientMode; auto enabled = writable && tlsChecked && !clientMode;
@ -258,7 +259,7 @@ void SettingsDialog::updateTlsControlsEnabled()
bool SettingsDialog::isClientMode() const bool SettingsDialog::isClientMode() const
{ {
return m_coreProcess.mode() == deskflow::gui::CoreProcess::Mode::Client; return m_coreProcess.mode() == Settings::CoreMode::Client;
} }
void SettingsDialog::updateKeyLengthOnFile(const QString &path) void SettingsDialog::updateKeyLengthOnFile(const QString &path)

View file

@ -39,6 +39,7 @@ public:
}; };
struct Core struct Core
{ {
inline static const auto CoreMode = QStringLiteral("core/coreMode");
inline static const auto ElevateMode = QStringLiteral("core/elevateMode"); inline static const auto ElevateMode = QStringLiteral("core/elevateMode");
inline static const auto Interface = QStringLiteral("core/interface"); inline static const auto Interface = QStringLiteral("core/interface");
inline static const auto LastVersion = QStringLiteral("core/lastVersion"); inline static const auto LastVersion = QStringLiteral("core/lastVersion");
@ -115,6 +116,14 @@ public:
}; };
Q_ENUM(ElevateMode) Q_ENUM(ElevateMode)
enum CoreMode
{
None,
Client,
Server
};
Q_ENUM(CoreMode)
static Settings *instance(); static Settings *instance();
static void setSettingFile(const QString &settingsFile = QString()); static void setSettingFile(const QString &settingsFile = QString());
static void setValue(const QString &key = QString(), const QVariant &value = QVariant()); static void setValue(const QString &key = QString(), const QVariant &value = QVariant());
@ -158,6 +167,7 @@ private:
, Client::InvertScrollDirection , Client::InvertScrollDirection
, Client::LanguageSync , Client::LanguageSync
, Client::RemoteHost , Client::RemoteHost
, Core::CoreMode
, Core::ElevateMode , Core::ElevateMode
, Core::Interface , Core::Interface
, Core::LastVersion , Core::LastVersion

View file

@ -51,11 +51,11 @@ const char *const AppConfig::m_SettingsName[] = {
"", // 17 = minimizeToTray, obsolete "", // 17 = minimizeToTray, obsolete
"", // 18 = ActivateEmail, obsolete "", // 18 = ActivateEmail, obsolete
"loadFromSystemScope", "loadFromSystemScope",
"groupServerChecked", // kServerGroupChecked "", // kServerGroupChecked
"", // 21 = use external config moved to deskflow settings "", // 21 = use external config moved to deskflow settings
"", // 22 config file moved to dekflow settings "", // 22 config file moved to dekflow settings
"useInternalConfig", "useInternalConfig",
"groupClientChecked", "", // Client groupchecked
"", // 25 server host name moved to deskflow settings "", // 25 server host name moved to deskflow settings
"", // 26 cert path moved to deskflow settings "", // 26 cert path moved to deskflow settings
"", // 27 key length Moved to Deskflow settings "", // 27 key length Moved to Deskflow settings
@ -106,9 +106,7 @@ void AppConfig::recallFromCurrentScope()
{ {
using enum Setting; using enum Setting;
m_ServerGroupChecked = getFromCurrentScope(kServerGroupChecked, m_ServerGroupChecked).toBool();
m_UseInternalConfig = getFromCurrentScope(kUseInternalConfig, m_UseInternalConfig).toBool(); m_UseInternalConfig = getFromCurrentScope(kUseInternalConfig, m_UseInternalConfig).toBool();
m_ClientGroupChecked = getFromCurrentScope(kClientGroupChecked, m_ClientGroupChecked).toBool();
} }
void AppConfig::commit() void AppConfig::commit()
@ -118,8 +116,6 @@ void AppConfig::commit()
qDebug("committing app config"); qDebug("committing app config");
saveToAllScopes(kLoadSystemSettings, m_LoadFromSystemScope); saveToAllScopes(kLoadSystemSettings, m_LoadFromSystemScope);
saveToAllScopes(kClientGroupChecked, m_ClientGroupChecked);
saveToAllScopes(kServerGroupChecked, m_ServerGroupChecked);
if (isActiveScopeWritable()) { if (isActiveScopeWritable()) {
setInCurrentScope(kUseInternalConfig, m_UseInternalConfig); setInCurrentScope(kUseInternalConfig, m_UseInternalConfig);
@ -282,21 +278,11 @@ IConfigScopes &AppConfig::scopes() const
return m_Scopes; return m_Scopes;
} }
bool AppConfig::serverGroupChecked() const
{
return m_ServerGroupChecked;
}
bool AppConfig::useInternalConfig() const bool AppConfig::useInternalConfig() const
{ {
return m_UseInternalConfig; return m_UseInternalConfig;
} }
bool AppConfig::clientGroupChecked() const
{
return m_ClientGroupChecked;
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// End getters // End getters
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -305,21 +291,11 @@ bool AppConfig::clientGroupChecked() const
// Begin setters // Begin setters
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void AppConfig::setServerGroupChecked(bool newValue)
{
m_ServerGroupChecked = newValue;
}
void AppConfig::setUseInternalConfig(bool newValue) void AppConfig::setUseInternalConfig(bool newValue)
{ {
m_UseInternalConfig = newValue; m_UseInternalConfig = newValue;
} }
void AppConfig::setClientGroupChecked(bool newValue)
{
m_ClientGroupChecked = newValue;
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// End setters // End setters
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View file

@ -58,33 +58,33 @@ private:
// 17 = minimize to tray, obsolete // 17 = minimize to tray, obsolete
// 18 = activate email, obsolete // 18 = activate email, obsolete
kLoadSystemSettings = 19, kLoadSystemSettings = 19,
kServerGroupChecked = 20, // kServerGroupChecked = 20,
// 21 = use external config moved to deskflow settings // 21 = use external config moved to deskflow settings
// 22 = k config file moved to deskflow settings // 22 = k config file moved to deskflow settings
kUseInternalConfig = 23, kUseInternalConfig = 23,
kClientGroupChecked = 24, // kClientGroupChecked = 24,
// 25 = serverHostName moved to deskflow settings // 25 = serverHostName moved to deskflow settings
// 26 = kTlsCertPath moved to deskflow settings // 26 = kTlsCertPath moved to deskflow settings
// 27 = tlsKeyLength Moved to deskflow settings // 27 = tlsKeyLength Moved to deskflow settings
// 28 = Prevent Sleep moved to deskflow settings // 28 = Prevent Sleep moved to deskflow settings
// 29 = language Sync moved to deskflow settings // 29 = language Sync moved to deskflow settings
// 30 = InvertScrollDirection moved to deskflow settings // 30 = InvertScrollDirection moved to deskflow settings
// 31 = guid, obsolete // 31 = guid, obsolete
// 32 = license registry url, obsolete // 32 = license registry url, obsolete
// 33 = license next check, obsolete // 33 = license next check, obsolete
// 34 = InvertConnection, obsolete // 34 = InvertConnection, obsolete
// 35 = client-host-mode, obsolete // 35 = client-host-mode, obsolete
// 36 = server-client-mode, obsolete // 36 = server-client-mode, obsolete
// kEnableService = 37, moved to deskflow settings // kEnableService = 37, moved to deskflow settings
// 38, close to tray moved to deskflow settings // 38, close to tray moved to deskflow settings
// 39 window size moved to deskflow settings // 39 window size moved to deskflow settings
// 40 window position moved to deskflow settings // 40 window position moved to deskflow settings
// 41 = show dev thanks, obsolete // 41 = show dev thanks, obsolete
// 42, close reminder moved to deskflow settings // 42, close reminder moved to deskflow settings
// 43 = Enable Update Check, // 43 = Enable Update Check,
// 44 = LogExpanded, Moved to deskflow settings // 44 = LogExpanded, Moved to deskflow settings
// 45 = Colorful Icon, Moved to deskflow settings // 45 = Colorful Icon, Moved to deskflow settings
// kRequireClientCert = 46 Moved to deskflow settings // kRequireClientCert = 46 Moved to deskflow settings
}; };
public: public:
@ -110,22 +110,18 @@ public:
IConfigScopes &scopes() const override; IConfigScopes &scopes() const override;
bool isActiveScopeWritable() const override; bool isActiveScopeWritable() const override;
bool isActiveScopeSystem() const override; bool isActiveScopeSystem() const override;
bool clientGroupChecked() const override;
// //
// Getters (new methods) // Getters (new methods)
// //
bool serverGroupChecked() const;
bool useInternalConfig() const; bool useInternalConfig() const;
// //
// Setters (new methods) // Setters (new methods)
// //
void setServerGroupChecked(bool);
void setUseInternalConfig(bool); void setUseInternalConfig(bool);
void setClientGroupChecked(bool);
/// @brief Sets the user preference to load from SystemScope. /// @brief Sets the user preference to load from SystemScope.
/// @param [in] value /// @param [in] value
@ -183,9 +179,7 @@ private:
/// @brief Contains the string values of the settings names that will be saved /// @brief Contains the string values of the settings names that will be saved
static const char *const m_SettingsName[]; static const char *const m_SettingsName[];
bool m_ServerGroupChecked = false;
bool m_UseInternalConfig = false; bool m_UseInternalConfig = false;
bool m_ClientGroupChecked = false;
bool m_LoadFromSystemScope = false; bool m_LoadFromSystemScope = false;
deskflow::gui::IConfigScopes &m_Scopes; deskflow::gui::IConfigScopes &m_Scopes;

View file

@ -26,7 +26,6 @@ public:
virtual IConfigScopes &scopes() const = 0; virtual IConfigScopes &scopes() const = 0;
virtual bool isActiveScopeSystem() const = 0; virtual bool isActiveScopeSystem() const = 0;
virtual bool isActiveScopeWritable() const = 0; virtual bool isActiveScopeWritable() const = 0;
virtual bool clientGroupChecked() const = 0;
// //
// Setters // Setters

View file

@ -380,10 +380,10 @@ void CoreProcess::start(std::optional<ProcessMode> processModeOption)
QStringList args; QStringList args;
addGenericArgs(args, processMode); addGenericArgs(args, processMode);
if (mode() == Mode::Server && !addServerArgs(args, app)) { if (mode() == Settings::CoreMode::Server && !addServerArgs(args, app)) {
qWarning("failed to add server args for core process, aborting start"); qWarning("failed to add server args for core process, aborting start");
return; return;
} else if (mode() == Mode::Client && !addClientArgs(args, app)) { } else if (mode() == Settings::CoreMode::Client && !addClientArgs(args, app)) {
qWarning("failed to add client args for core process, aborting start"); qWarning("failed to add client args for core process, aborting start");
return; return;
} }
@ -620,12 +620,10 @@ QString CoreProcess::persistServerConfig() const
QString CoreProcess::modeString() const QString CoreProcess::modeString() const
{ {
using enum Mode;
switch (m_mode) { switch (m_mode) {
case Server: case Settings::CoreMode::Server:
return "server"; return "server";
case Client: case Settings::CoreMode::Client:
return "client"; return "client";
default: default:
qFatal("invalid core mode"); qFatal("invalid core mode");

View file

@ -50,12 +50,6 @@ public:
QProcessProxy m_process; QProcessProxy m_process;
}; };
enum class Mode
{
None,
Client,
Server
};
enum class Error enum class Error
{ {
AddressMissing, AddressMissing,
@ -88,7 +82,7 @@ public:
void clearSettings(); void clearSettings();
// getters // getters
Mode mode() const Settings::CoreMode mode() const
{ {
return m_mode; return m_mode;
} }
@ -114,7 +108,7 @@ public:
{ {
m_address = address.trimmed(); m_address = address.trimmed();
} }
void setMode(Mode mode) void setMode(Settings::CoreMode mode)
{ {
m_mode = mode; m_mode = mode;
} }
@ -163,7 +157,7 @@ private:
QString m_address; QString m_address;
ProcessState m_processState = ProcessState::Stopped; ProcessState m_processState = ProcessState::Stopped;
ConnectionState m_connectionState = ConnectionState::Disconnected; ConnectionState m_connectionState = ConnectionState::Disconnected;
Mode m_mode = Mode::None; Settings::CoreMode m_mode = Settings::CoreMode::None;
QMutex m_processMutex; QMutex m_processMutex;
QString m_secureSocketVersion = ""; QString m_secureSocketVersion = "";
std::optional<ProcessMode> m_lastProcessMode = std::nullopt; std::optional<ProcessMode> m_lastProcessMode = std::nullopt;

View file

@ -6,6 +6,7 @@
#include "WaylandWarnings.h" #include "WaylandWarnings.h"
#include "common/Settings.h"
#include "messages.h" #include "messages.h"
using namespace deskflow::platform; using namespace deskflow::platform;
@ -25,12 +26,10 @@ void WaylandWarnings::Deps::showWaylandLibraryError(QWidget *parent)
// WaylandWarnings // WaylandWarnings
// //
void WaylandWarnings::showOnce( void WaylandWarnings::showOnce(QWidget *parent, bool hasEi, bool hasPortal, bool hasPortalInputCapture)
QWidget *parent, CoreProcess::Mode mode, bool hasEi, bool hasPortal, bool hasPortalInputCapture
)
{ {
const auto mode = Settings::value(Settings::Core::CoreMode).value<Settings::CoreMode>();
const auto portalIcProblem = !hasPortalInputCapture && mode == CoreProcess::Mode::Server; const bool portalIcProblem = !hasPortalInputCapture && mode == Settings::CoreMode::Server;
if (!hasEi || !hasPortal || portalIcProblem) { if (!hasEi || !hasPortal || portalIcProblem) {
if (!m_errorShown) { if (!m_errorShown) {

View file

@ -9,7 +9,6 @@
#include <QWidget> #include <QWidget>
#include <memory> #include <memory>
#include "CoreProcess.h"
#include "platform/wayland.h" #include "platform/wayland.h"
namespace deskflow::gui::core { namespace deskflow::gui::core {
@ -28,7 +27,7 @@ public:
} }
void showOnce( void showOnce(
QWidget *parent, CoreProcess::Mode mode, bool hasEi = platform::kHasEi, bool hasPortal = platform::kHasPortal, QWidget *parent, bool hasEi = platform::kHasEi, bool hasPortal = platform::kHasPortal,
bool hasPortalInputCapture = platform::kHasPortalInputCapture bool hasPortalInputCapture = platform::kHasPortalInputCapture
); );

View file

@ -25,7 +25,6 @@ public:
MOCK_METHOD(deskflow::gui::IConfigScopes &, scopes, (), (const, override)); MOCK_METHOD(deskflow::gui::IConfigScopes &, scopes, (), (const, override));
MOCK_METHOD(bool, isActiveScopeSystem, (), (const, override)); MOCK_METHOD(bool, isActiveScopeSystem, (), (const, override));
MOCK_METHOD(bool, isActiveScopeWritable, (), (const, override)); MOCK_METHOD(bool, isActiveScopeWritable, (), (const, override));
MOCK_METHOD(bool, clientGroupChecked, (), (const, override));
// //
// Setters // Setters

View file

@ -86,7 +86,7 @@ private:
TEST_F(CoreProcessTests, start_serverDesktop_callsProcessStart) TEST_F(CoreProcessTests, start_serverDesktop_callsProcessStart)
{ {
m_coreProcess.setMode(CoreProcess::Mode::Server); m_coreProcess.setMode(Settings::CoreMode::Server);
EXPECT_CALL(m_pDeps->m_process, start(_, _)).Times(1); EXPECT_CALL(m_pDeps->m_process, start(_, _)).Times(1);
@ -95,7 +95,7 @@ TEST_F(CoreProcessTests, start_serverDesktop_callsProcessStart)
TEST_F(CoreProcessTests, start_clientDesktop_callsProcessStart) TEST_F(CoreProcessTests, start_clientDesktop_callsProcessStart)
{ {
m_coreProcess.setMode(CoreProcess::Mode::Client); m_coreProcess.setMode(Settings::CoreMode::Client);
m_coreProcess.setAddress("stub address"); m_coreProcess.setAddress("stub address");
EXPECT_CALL(m_pDeps->m_process, start(_, _)).Times(1); EXPECT_CALL(m_pDeps->m_process, start(_, _)).Times(1);
@ -105,7 +105,7 @@ TEST_F(CoreProcessTests, start_clientDesktop_callsProcessStart)
TEST_F(CoreProcessTests, stop_serverDesktop_callsProcessClose) TEST_F(CoreProcessTests, stop_serverDesktop_callsProcessClose)
{ {
m_coreProcess.setMode(CoreProcess::Mode::Server); m_coreProcess.setMode(Settings::CoreMode::Server);
m_coreProcess.start(); m_coreProcess.start();
EXPECT_CALL(m_pDeps->m_process, close()).Times(1); EXPECT_CALL(m_pDeps->m_process, close()).Times(1);
@ -115,7 +115,7 @@ TEST_F(CoreProcessTests, stop_serverDesktop_callsProcessClose)
TEST_F(CoreProcessTests, stop_clientDesktop_callsProcessClose) TEST_F(CoreProcessTests, stop_clientDesktop_callsProcessClose)
{ {
m_coreProcess.setMode(CoreProcess::Mode::Client); m_coreProcess.setMode(Settings::CoreMode::Client);
m_coreProcess.setAddress("stub address"); m_coreProcess.setAddress("stub address");
m_coreProcess.start(); m_coreProcess.start();
@ -127,7 +127,7 @@ TEST_F(CoreProcessTests, stop_clientDesktop_callsProcessClose)
TEST_F(CoreProcessTests, restart_serverDesktop_callsProcessStart) TEST_F(CoreProcessTests, restart_serverDesktop_callsProcessStart)
{ {
Settings::setValue(Settings::Core::ProcessMode, Settings::ProcessMode::Desktop); Settings::setValue(Settings::Core::ProcessMode, Settings::ProcessMode::Desktop);
m_coreProcess.setMode(CoreProcess::Mode::Server); m_coreProcess.setMode(Settings::CoreMode::Server);
m_coreProcess.start(); m_coreProcess.start();
EXPECT_CALL(m_pDeps->m_process, close()).Times(1); EXPECT_CALL(m_pDeps->m_process, close()).Times(1);

View file

@ -29,10 +29,11 @@ TEST(WaylandWarningsTests, showOnce_serverNoEi_showLibraryError)
const bool hasPortal = false; const bool hasPortal = false;
const bool hasPortalIC = false; const bool hasPortalIC = false;
WaylandWarnings waylandWarnings(deps); WaylandWarnings waylandWarnings(deps);
Settings::setValue(Settings::Core::CoreMode, Settings::CoreMode::Server);
EXPECT_CALL(*deps, showWaylandLibraryError(nullptr)).Times(1); EXPECT_CALL(*deps, showWaylandLibraryError(nullptr)).Times(1);
waylandWarnings.showOnce(nullptr, CoreProcess::Mode::Server, hasEi, hasPortal, hasPortalIC); waylandWarnings.showOnce(nullptr, hasEi, hasPortal, hasPortalIC);
} }
TEST(WaylandWarningsTests, showOnce_serverNoPortal_showLibraryError) TEST(WaylandWarningsTests, showOnce_serverNoPortal_showLibraryError)
@ -42,10 +43,11 @@ TEST(WaylandWarningsTests, showOnce_serverNoPortal_showLibraryError)
const bool hasPortal = false; const bool hasPortal = false;
const bool hasPortalIC = false; const bool hasPortalIC = false;
WaylandWarnings waylandWarnings(deps); WaylandWarnings waylandWarnings(deps);
Settings::setValue(Settings::Core::CoreMode, Settings::CoreMode::Server);
EXPECT_CALL(*deps, showWaylandLibraryError(nullptr)).Times(1); EXPECT_CALL(*deps, showWaylandLibraryError(nullptr)).Times(1);
waylandWarnings.showOnce(nullptr, CoreProcess::Mode::Server, hasEi, hasPortal, hasPortalIC); waylandWarnings.showOnce(nullptr, hasEi, hasPortal, hasPortalIC);
} }
TEST(WaylandWarningsTests, showOnce_serverNoPortalIc_showLibraryError) TEST(WaylandWarningsTests, showOnce_serverNoPortalIc_showLibraryError)
@ -55,10 +57,11 @@ TEST(WaylandWarningsTests, showOnce_serverNoPortalIc_showLibraryError)
const bool hasPortal = true; const bool hasPortal = true;
const bool hasPortalIC = false; const bool hasPortalIC = false;
WaylandWarnings waylandWarnings(deps); WaylandWarnings waylandWarnings(deps);
Settings::setValue(Settings::Core::CoreMode, Settings::CoreMode::Server);
EXPECT_CALL(*deps, showWaylandLibraryError(nullptr)).Times(1); EXPECT_CALL(*deps, showWaylandLibraryError(nullptr)).Times(1);
waylandWarnings.showOnce(nullptr, CoreProcess::Mode::Server, hasEi, hasPortal, hasPortalIC); waylandWarnings.showOnce(nullptr, hasEi, hasPortal, hasPortalIC);
} }
TEST(WaylandWarningsTests, showOnce_failureCalledTwice_messageOnlyShownOnce) TEST(WaylandWarningsTests, showOnce_failureCalledTwice_messageOnlyShownOnce)
@ -68,9 +71,10 @@ TEST(WaylandWarningsTests, showOnce_failureCalledTwice_messageOnlyShownOnce)
const bool hasPortal = false; const bool hasPortal = false;
const bool hasPortalIC = false; const bool hasPortalIC = false;
WaylandWarnings waylandWarnings(deps); WaylandWarnings waylandWarnings(deps);
Settings::setValue(Settings::Core::CoreMode, Settings::CoreMode::Server);
EXPECT_CALL(*deps, showWaylandLibraryError(nullptr)).Times(1); EXPECT_CALL(*deps, showWaylandLibraryError(nullptr)).Times(1);
waylandWarnings.showOnce(nullptr, CoreProcess::Mode::Server, hasEi, hasPortal, hasPortalIC); waylandWarnings.showOnce(nullptr, hasEi, hasPortal, hasPortalIC);
waylandWarnings.showOnce(nullptr, CoreProcess::Mode::Server, hasEi, hasPortal, hasPortalIC); waylandWarnings.showOnce(nullptr, hasEi, hasPortal, hasPortalIC);
} }