diff --git a/src/lib/server/Server.cpp b/src/lib/server/Server.cpp index 91939b3d9..6c9ec1be5 100644 --- a/src/lib/server/Server.cpp +++ b/src/lib/server/Server.cpp @@ -44,8 +44,7 @@ Server::Server( ServerConfig &config, PrimaryClient *primaryClient, deskflow::Screen *screen, IEventQueue *events, deskflow::ServerArgs const &args ) - : m_mock(false), - m_primaryClient(primaryClient), + : m_primaryClient(primaryClient), m_active(primaryClient), m_seqNum(0), m_xDelta(0), @@ -178,10 +177,6 @@ Server::Server( Server::~Server() { - if (m_mock) { - return; - } - // remove event handlers and timers m_events->removeHandler(EventTypes::KeyStateKeyDown, m_inputFilter); m_events->removeHandler(EventTypes::KeyStateKeyUp, m_inputFilter); diff --git a/src/lib/server/Server.h b/src/lib/server/Server.h index 7ff430ba5..02fb6ceec 100644 --- a/src/lib/server/Server.h +++ b/src/lib/server/Server.h @@ -129,16 +129,6 @@ public: Server &operator=(Server const &) = delete; Server &operator=(Server &&) = delete; -#ifdef TEST_ENV - Server() : m_mock(true), m_config(nullptr) - { - } - void setActive(BaseClientProxy *active) - { - m_active = active; - } -#endif - //! @name manipulators //@{ @@ -356,9 +346,6 @@ private: // force the cursor off of \p client void forceLeaveClient(BaseClientProxy *client); -public: - bool m_mock; - private: class ClipboardInfo { diff --git a/src/test/unittests/server/ServerTests.cpp b/src/test/unittests/server/ServerTests.cpp deleted file mode 100644 index 63ad14513..000000000 --- a/src/test/unittests/server/ServerTests.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2014 - 2016 Symless Ltd. - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#include "lib/server/Server.h" - -#include - -TEST(ServerTests, SwitchToScreenInfo_alloc_screen) -{ - auto info = Server::SwitchToScreenInfo::alloc("test"); - - EXPECT_STREQ(info->m_screen, "test"); -} - -TEST(ServerTests, KeyboardBroadcastInfo_alloc_stateAndSceens) -{ - auto info = Server::KeyboardBroadcastInfo::alloc(Server::KeyboardBroadcastInfo::State::kOn, "test"); - - EXPECT_EQ(info->m_state, Server::KeyboardBroadcastInfo::State::kOn); - EXPECT_STREQ(info->m_screens, "test"); -} diff --git a/src/unittests/CMakeLists.txt b/src/unittests/CMakeLists.txt index 11f5849f3..0202e4f75 100644 --- a/src/unittests/CMakeLists.txt +++ b/src/unittests/CMakeLists.txt @@ -47,6 +47,7 @@ add_subdirectory(common) add_subdirectory(deskflow) add_subdirectory(gui) add_subdirectory(platform) +add_subdirectory(server) #make sure to use CI only plugin on Unix if (UNIX AND NOT APPLE) diff --git a/src/unittests/server/CMakeLists.txt b/src/unittests/server/CMakeLists.txt new file mode 100644 index 000000000..0d43f534c --- /dev/null +++ b/src/unittests/server/CMakeLists.txt @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2025 Deskflow Developers +# SPDX-License-Identifier: MIT + +if(WIN32) + set(extra_libs version ${cli11_lib} ${tomlPP_lib} app mt net) +endif() + +create_test( + NAME ServerTests + DEPENDS server + LIBS base arch ${extra_libs} + SOURCE ServerTests.cpp + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src/lib/server" +) + diff --git a/src/unittests/server/ServerTests.cpp b/src/unittests/server/ServerTests.cpp new file mode 100644 index 000000000..cf46ca0dc --- /dev/null +++ b/src/unittests/server/ServerTests.cpp @@ -0,0 +1,25 @@ +/* + * Deskflow -- mouse and keyboard sharing utility + * SPDX-FileCopyrightText: (C) 2025 Chris Rizzitello + * SPDX-FileCopyrightText: (C) 2014 - 2016 Symless Ltd. + * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception + */ + +#include "ServerTests.h" + +#include "../../lib/server/Server.h" + +void ServerTests::SwitchToScreenInfo_alloc_screen() +{ + auto actual = Server::SwitchToScreenInfo::alloc("test"); + QCOMPARE(actual->m_screen, "test"); +} + +void ServerTests::KeyboardBroadcastInfo_alloc_stateAndSceens() +{ + auto info = Server::KeyboardBroadcastInfo::alloc(Server::KeyboardBroadcastInfo::State::kOn, "test"); + QCOMPARE(info->m_state, Server::KeyboardBroadcastInfo::State::kOn); + QCOMPARE(info->m_screens, "test"); +} + +QTEST_MAIN(ServerTests) diff --git a/src/unittests/server/ServerTests.h b/src/unittests/server/ServerTests.h new file mode 100644 index 000000000..43cf5e7b6 --- /dev/null +++ b/src/unittests/server/ServerTests.h @@ -0,0 +1,15 @@ +/* + * Deskflow -- mouse and keyboard sharing utility + * SPDX-FileCopyrightText: (C) 2025 Chris Rizzitello + * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception + */ + +#include + +class ServerTests : public QObject +{ + Q_OBJECT +private slots: + void SwitchToScreenInfo_alloc_screen(); + void KeyboardBroadcastInfo_alloc_stateAndSceens(); +};