refactor: port ServerTests to QtTests
remove TEST_ENV items from Server
This commit is contained in:
parent
d742901775
commit
b56a282a9c
7 changed files with 57 additions and 43 deletions
|
|
@ -44,8 +44,7 @@ Server::Server(
|
||||||
ServerConfig &config, PrimaryClient *primaryClient, deskflow::Screen *screen, IEventQueue *events,
|
ServerConfig &config, PrimaryClient *primaryClient, deskflow::Screen *screen, IEventQueue *events,
|
||||||
deskflow::ServerArgs const &args
|
deskflow::ServerArgs const &args
|
||||||
)
|
)
|
||||||
: m_mock(false),
|
: m_primaryClient(primaryClient),
|
||||||
m_primaryClient(primaryClient),
|
|
||||||
m_active(primaryClient),
|
m_active(primaryClient),
|
||||||
m_seqNum(0),
|
m_seqNum(0),
|
||||||
m_xDelta(0),
|
m_xDelta(0),
|
||||||
|
|
@ -178,10 +177,6 @@ Server::Server(
|
||||||
|
|
||||||
Server::~Server()
|
Server::~Server()
|
||||||
{
|
{
|
||||||
if (m_mock) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove event handlers and timers
|
// remove event handlers and timers
|
||||||
m_events->removeHandler(EventTypes::KeyStateKeyDown, m_inputFilter);
|
m_events->removeHandler(EventTypes::KeyStateKeyDown, m_inputFilter);
|
||||||
m_events->removeHandler(EventTypes::KeyStateKeyUp, m_inputFilter);
|
m_events->removeHandler(EventTypes::KeyStateKeyUp, m_inputFilter);
|
||||||
|
|
|
||||||
|
|
@ -129,16 +129,6 @@ public:
|
||||||
Server &operator=(Server const &) = delete;
|
Server &operator=(Server const &) = delete;
|
||||||
Server &operator=(Server &&) = 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
|
//! @name manipulators
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
|
|
@ -356,9 +346,6 @@ private:
|
||||||
// force the cursor off of \p client
|
// force the cursor off of \p client
|
||||||
void forceLeaveClient(BaseClientProxy *client);
|
void forceLeaveClient(BaseClientProxy *client);
|
||||||
|
|
||||||
public:
|
|
||||||
bool m_mock;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class ClipboardInfo
|
class ClipboardInfo
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -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 <gtest/gtest.h>
|
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
@ -47,6 +47,7 @@ add_subdirectory(common)
|
||||||
add_subdirectory(deskflow)
|
add_subdirectory(deskflow)
|
||||||
add_subdirectory(gui)
|
add_subdirectory(gui)
|
||||||
add_subdirectory(platform)
|
add_subdirectory(platform)
|
||||||
|
add_subdirectory(server)
|
||||||
|
|
||||||
#make sure to use CI only plugin on Unix
|
#make sure to use CI only plugin on Unix
|
||||||
if (UNIX AND NOT APPLE)
|
if (UNIX AND NOT APPLE)
|
||||||
|
|
|
||||||
15
src/unittests/server/CMakeLists.txt
Normal file
15
src/unittests/server/CMakeLists.txt
Normal file
|
|
@ -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"
|
||||||
|
)
|
||||||
|
|
||||||
25
src/unittests/server/ServerTests.cpp
Normal file
25
src/unittests/server/ServerTests.cpp
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* Deskflow -- mouse and keyboard sharing utility
|
||||||
|
* SPDX-FileCopyrightText: (C) 2025 Chris Rizzitello <sithlord48@gmail.com>
|
||||||
|
* 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)
|
||||||
15
src/unittests/server/ServerTests.h
Normal file
15
src/unittests/server/ServerTests.h
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
/*
|
||||||
|
* Deskflow -- mouse and keyboard sharing utility
|
||||||
|
* SPDX-FileCopyrightText: (C) 2025 Chris Rizzitello <sithlord48@gmail.com>
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <QTest>
|
||||||
|
|
||||||
|
class ServerTests : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
private slots:
|
||||||
|
void SwitchToScreenInfo_alloc_screen();
|
||||||
|
void KeyboardBroadcastInfo_alloc_stateAndSceens();
|
||||||
|
};
|
||||||
Loading…
Reference in a new issue