aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2021-11-10 00:54:13 -0500
committerLibravatarUnit 193 <unit193@unit193.net>2021-11-10 00:54:13 -0500
commitbeb08eb751fa8e1f72042f263316ab5e5ddb596d (patch)
tree3b00df983527648bdae610ac7b88cb639b1f1828 /src/test
parentfbc30002ab3438356c0476e70c4577a0310d52c0 (diff)
New upstream version 2.4.0+dfsg.upstream/2.4.0+dfsgupstream
Diffstat (limited to 'src/test')
-rw-r--r--src/test/CMakeLists.txt33
-rw-r--r--src/test/global/TestEventQueue.cpp6
-rw-r--r--src/test/global/TestEventQueue.h4
-rw-r--r--src/test/global/TestUtils.cpp37
-rw-r--r--src/test/global/TestUtils.h30
-rw-r--r--src/test/global/gmock.h4
-rw-r--r--src/test/global/gtest.h4
-rw-r--r--src/test/guitests/src/VersionCheckerTests.cpp4
-rw-r--r--src/test/guitests/src/VersionCheckerTests.h4
-rw-r--r--src/test/guitests/src/main.cpp4
-rw-r--r--src/test/integtests/CMakeLists.txt8
-rw-r--r--src/test/integtests/Main.cpp12
-rw-r--r--src/test/integtests/ipc/IpcTests.cpp21
-rw-r--r--src/test/integtests/net/NetworkTests.cpp79
-rw-r--r--src/test/integtests/platform/MSWindowsClipboardTests.cpp6
-rw-r--r--src/test/integtests/platform/MSWindowsKeyStateTests.cpp16
-rw-r--r--src/test/integtests/platform/OSXClipboardTests.cpp56
-rw-r--r--src/test/integtests/platform/OSXScreenTests.cpp4
-rw-r--r--src/test/integtests/platform/XWindowsClipboardTests.cpp44
-rw-r--r--src/test/integtests/platform/XWindowsKeyStateTests.cpp2
-rw-r--r--src/test/integtests/platform/XWindowsScreenSaverTests.cpp8
-rw-r--r--src/test/integtests/platform/XWindowsScreenTests.cpp8
-rw-r--r--src/test/mock/barrier/MockApp.h2
-rw-r--r--src/test/mock/barrier/MockArgParser.h2
-rw-r--r--src/test/mock/barrier/MockEventQueue.h4
-rw-r--r--src/test/mock/barrier/MockKeyState.h4
-rw-r--r--src/test/mock/barrier/MockScreen.h2
-rw-r--r--src/test/mock/ipc/MockIpcServer.h2
-rw-r--r--src/test/mock/server/MockConfig.h2
-rw-r--r--src/test/mock/server/MockInputFilter.h2
-rw-r--r--src/test/mock/server/MockPrimaryClient.h2
-rw-r--r--src/test/mock/server/MockServer.h2
-rw-r--r--src/test/unittests/CMakeLists.txt8
-rw-r--r--src/test/unittests/Main.cpp8
-rw-r--r--src/test/unittests/barrier/ArgParserTests.cpp4
-rw-r--r--src/test/unittests/barrier/ClientArgsParsingTests.cpp4
-rw-r--r--src/test/unittests/barrier/ClipboardChunkTests.cpp4
-rw-r--r--src/test/unittests/barrier/ClipboardTests.cpp16
-rw-r--r--src/test/unittests/barrier/GenericArgsParsingTests.cpp36
-rw-r--r--src/test/unittests/barrier/KeyMapTests.cpp42
-rw-r--r--src/test/unittests/barrier/KeyStateTests.cpp12
-rw-r--r--src/test/unittests/base/StringTests.cpp36
-rw-r--r--src/test/unittests/ipc/IpcLogOutputterTests.cpp20
-rw-r--r--src/test/unittests/net/FingerprintDatabaseTests.cpp95
-rw-r--r--src/test/unittests/net/SecureUtilsTests.cpp73
-rw-r--r--src/test/unittests/platform/OSXKeyStateTests.cpp12
46 files changed, 511 insertions, 277 deletions
diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt
deleted file mode 100644
index daecb31..0000000
--- a/src/test/CMakeLists.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-# barrier -- mouse and keyboard sharing utility
-# Copyright (C) 2012-2016 Symless Ltd.
-# Copyright (C) 2011 Nick Bolton
-#
-# This package is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# found in the file LICENSE that should have accompanied this file.
-#
-# This package is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-include_directories(
- ../../ext/gtest
- ../../ext/gtest/include
- ../../ext/gmock
- ../../ext/gmock/include)
-
-add_library(gtest STATIC ../../ext/gtest/src/gtest-all.cc)
-add_library(gmock STATIC ../../ext/gmock/src/gmock-all.cc)
-
-if (UNIX)
- # ignore warnings in gtest and gmock
- set_target_properties(gtest PROPERTIES COMPILE_FLAGS "-w")
- set_target_properties(gmock PROPERTIES COMPILE_FLAGS "-w")
-endif()
-
-add_subdirectory(integtests)
-add_subdirectory(unittests)
diff --git a/src/test/global/TestEventQueue.cpp b/src/test/global/TestEventQueue.cpp
index 4dd01e7..253e9ab 100644
--- a/src/test/global/TestEventQueue.cpp
+++ b/src/test/global/TestEventQueue.cpp
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2013-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -23,7 +23,7 @@
#include <stdexcept>
void
-TestEventQueue::raiseQuitEvent()
+TestEventQueue::raiseQuitEvent()
{
addEvent(Event(Event::kQuit));
}
diff --git a/src/test/global/TestEventQueue.h b/src/test/global/TestEventQueue.h
index b932508..14568b6 100644
--- a/src/test/global/TestEventQueue.h
+++ b/src/test/global/TestEventQueue.h
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2013-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/test/global/TestUtils.cpp b/src/test/global/TestUtils.cpp
new file mode 100644
index 0000000..6a3193b
--- /dev/null
+++ b/src/test/global/TestUtils.cpp
@@ -0,0 +1,37 @@
+/*
+ barrier -- mouse and keyboard sharing utility
+ Copyright (C) Barrier contributors
+
+ This package is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ found in the file LICENSE that should have accompanied this file.
+
+ This package is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "TestUtils.h"
+#include <random>
+
+namespace barrier {
+
+std::vector<std::uint8_t> generate_pseudo_random_bytes(std::size_t seed, std::size_t size)
+{
+ std::mt19937_64 engine{seed};
+ std::uniform_int_distribution<int> dist{0, 255};
+ std::vector<std::uint8_t> bytes;
+
+ bytes.reserve(size);
+ for (std::size_t i = 0; i < size; ++i) {
+ bytes.push_back(dist(engine));
+ }
+
+ return bytes;
+}
+
+} // namespace barrier
diff --git a/src/test/global/TestUtils.h b/src/test/global/TestUtils.h
new file mode 100644
index 0000000..31050ec
--- /dev/null
+++ b/src/test/global/TestUtils.h
@@ -0,0 +1,30 @@
+/*
+ barrier -- mouse and keyboard sharing utility
+ Copyright (C) Barrier contributors
+
+ This package is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ found in the file LICENSE that should have accompanied this file.
+
+ This package is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef BARRIER_TEST_GLOBAL_TEST_UTILS_H
+#define BARRIER_TEST_GLOBAL_TEST_UTILS_H
+
+#include <cstdint>
+#include <vector>
+
+namespace barrier {
+
+std::vector<std::uint8_t> generate_pseudo_random_bytes(std::size_t seed, std::size_t size);
+
+} // namespace barrier
+
+#endif // BARRIER_TEST_GLOBAL_TEST_UTILS_H
diff --git a/src/test/global/gmock.h b/src/test/global/gmock.h
index 64597f4..8a27440 100644
--- a/src/test/global/gmock.h
+++ b/src/test/global/gmock.h
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2014-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/test/global/gtest.h b/src/test/global/gtest.h
index 0b2acbc..55cb10f 100644
--- a/src/test/global/gtest.h
+++ b/src/test/global/gtest.h
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2014-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/test/guitests/src/VersionCheckerTests.cpp b/src/test/guitests/src/VersionCheckerTests.cpp
index 0efc5f9..82212a7 100644
--- a/src/test/guitests/src/VersionCheckerTests.cpp
+++ b/src/test/guitests/src/VersionCheckerTests.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2012 Nick Bolton
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/test/guitests/src/VersionCheckerTests.h b/src/test/guitests/src/VersionCheckerTests.h
index 7884f3a..4273701 100644
--- a/src/test/guitests/src/VersionCheckerTests.h
+++ b/src/test/guitests/src/VersionCheckerTests.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2012 Nick Bolton
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/test/guitests/src/main.cpp b/src/test/guitests/src/main.cpp
index 2ff6e72..6b7677e 100644
--- a/src/test/guitests/src/main.cpp
+++ b/src/test/guitests/src/main.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2012 Nick Bolton
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/test/integtests/CMakeLists.txt b/src/test/integtests/CMakeLists.txt
index 0460d8d..cdb8844 100644
--- a/src/test/integtests/CMakeLists.txt
+++ b/src/test/integtests/CMakeLists.txt
@@ -1,11 +1,11 @@
# barrier -- mouse and keyboard sharing utility
# Copyright (C) 2012-2016 Symless Ltd.
# Copyright (C) 2009 Nick Bolton
-#
+#
# This package is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# found in the file LICENSE that should have accompanied this file.
-#
+#
# This package is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -68,8 +68,6 @@ endif()
include_directories(
../../
- ../../../ext/gtest/include
- ../../../ext/gmock/include
)
if (UNIX)
@@ -80,4 +78,4 @@ endif()
add_executable(integtests ${sources})
target_link_libraries(integtests
- arch base client common io ipc mt net platform server synlib gtest gmock ${libs} ${OPENSSL_LIBS})
+ arch base client common io ipc mt net platform server synlib ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} ${libs} ${OPENSSL_LIBS})
diff --git a/src/test/integtests/Main.cpp b/src/test/integtests/Main.cpp
index 76b42b6..f4eaca7 100644
--- a/src/test/integtests/Main.cpp
+++ b/src/test/integtests/Main.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2011 Nick Bolton
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -44,7 +44,7 @@ main(int argc, char **argv)
Arch arch;
arch.init();
-
+
Log log;
log.setFilter(kDEBUG2);
@@ -67,7 +67,7 @@ main(int argc, char **argv)
if (!lockFile.empty()) {
unlock(lockFile);
}
-
+
// gtest seems to randomly finish with error codes (e.g. -1, -1073741819)
// even when no tests have failed. not sure what causes this, but it
// happens on all platforms and keeps leading to false positives.
@@ -80,7 +80,7 @@ void
lock(string lockFile)
{
double start = ARCH->time();
-
+
// keep checking until timeout is reached.
while ((ARCH->time() - start) < LOCK_TIMEOUT) {
@@ -102,7 +102,7 @@ lock(string lockFile)
}
void
-unlock(string lockFile)
+unlock(string lockFile)
{
remove(lockFile.c_str());
}
diff --git a/src/test/integtests/ipc/IpcTests.cpp b/src/test/integtests/ipc/IpcTests.cpp
index a0ee241..ce15d59 100644
--- a/src/test/integtests/ipc/IpcTests.cpp
+++ b/src/test/integtests/ipc/IpcTests.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2012 Nick Bolton
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -19,7 +19,7 @@
// TODO: fix, tests failing intermittently on mac.
#ifndef WINAPI_CARBON
-#define TEST_ENV
+#define BARRIER_TEST_ENV
#include "test/global/TestEventQueue.h"
#include "ipc/IpcServer.h"
@@ -31,7 +31,6 @@
#include "net/SocketMultiplexer.h"
#include "mt/Thread.h"
#include "arch/Arch.h"
-#include "base/TMethodJob.h"
#include "base/String.h"
#include "base/Log.h"
#include "base/EventQueue.h"
@@ -46,7 +45,7 @@ class IpcTests : public ::testing::Test
public:
IpcTests();
virtual ~IpcTests();
-
+
void connectToServer_handleMessageReceived(const Event&, void*);
void sendMessageToServer_serverHandleMessageReceived(const Event&, void*);
void sendMessageToClient_serverHandleClientConnected(const Event&, void*);
@@ -76,15 +75,15 @@ TEST_F(IpcTests, connectToServer)
m_events.forIpcServer().messageReceived(), &server,
new TMethodEventJob<IpcTests>(
this, &IpcTests::connectToServer_handleMessageReceived));
-
+
IpcClient client(&m_events, &socketMultiplexer, TEST_IPC_PORT);
client.connect();
-
+
m_events.initQuitTimeout(5);
m_events.loop();
m_events.removeHandler(m_events.forIpcServer().messageReceived(), &server);
m_events.cleanupQuitTimeout();
-
+
EXPECT_EQ(true, m_connectToServer_helloMessageReceived);
EXPECT_EQ(true, m_connectToServer_hasClientNode);
}
@@ -94,13 +93,13 @@ TEST_F(IpcTests, sendMessageToServer)
SocketMultiplexer socketMultiplexer;
IpcServer server(&m_events, &socketMultiplexer, TEST_IPC_PORT);
server.listen();
-
+
// event handler sends "test" command to server.
m_events.adoptHandler(
m_events.forIpcServer().messageReceived(), &server,
new TMethodEventJob<IpcTests>(
this, &IpcTests::sendMessageToServer_serverHandleMessageReceived));
-
+
IpcClient client(&m_events, &socketMultiplexer, TEST_IPC_PORT);
client.connect();
m_sendMessageToServer_client = &client;
@@ -128,7 +127,7 @@ TEST_F(IpcTests, sendMessageToClient)
IpcClient client(&m_events, &socketMultiplexer, TEST_IPC_PORT);
client.connect();
-
+
m_events.adoptHandler(
m_events.forIpcClient().messageReceived(), &client,
new TMethodEventJob<IpcTests>(
diff --git a/src/test/integtests/net/NetworkTests.cpp b/src/test/integtests/net/NetworkTests.cpp
index d404abc..92767bf 100644
--- a/src/test/integtests/net/NetworkTests.cpp
+++ b/src/test/integtests/net/NetworkTests.cpp
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2013-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -18,7 +18,7 @@
// TODO: fix, tests failing intermittently on mac.
#ifndef WINAPI_CARBON
-#define TEST_ENV
+#define BARRIER_TEST_ENV
#include "test/mock/server/MockConfig.h"
#include "test/mock/server/MockPrimaryClient.h"
@@ -36,7 +36,6 @@
#include "net/TCPSocketFactory.h"
#include "mt/Thread.h"
#include "base/TMethodEventJob.h"
-#include "base/TMethodJob.h"
#include "base/Log.h"
#include <stdexcept>
@@ -84,19 +83,19 @@ public:
}
void sendMockData(void* eventTarget);
-
+
void sendToClient_mockData_handleClientConnected(const Event&, void* vlistener);
void sendToClient_mockData_fileRecieveCompleted(const Event&, void*);
-
+
void sendToClient_mockFile_handleClientConnected(const Event&, void* vlistener);
void sendToClient_mockFile_fileRecieveCompleted(const Event& event, void*);
-
+
void sendToServer_mockData_handleClientConnected(const Event&, void* vlistener);
void sendToServer_mockData_fileRecieveCompleted(const Event& event, void*);
void sendToServer_mockFile_handleClientConnected(const Event&, void* vlistener);
void sendToServer_mockFile_fileRecieveCompleted(const Event& event, void*);
-
+
public:
TestEventQueue m_events;
UInt8* m_mockData;
@@ -111,16 +110,17 @@ TEST_F(NetworkTests, sendToClient_mockData)
NetworkAddress serverAddress(TEST_HOST, TEST_PORT);
serverAddress.resolve();
-
+
// server
SocketMultiplexer serverSocketMultiplexer;
TCPSocketFactory* serverSocketFactory = new TCPSocketFactory(&m_events, &serverSocketMultiplexer);
- ClientListener listener(serverAddress, serverSocketFactory, &m_events, false);
+ ClientListener listener(serverAddress, serverSocketFactory, &m_events,
+ ConnectionSecurityLevel::PLAINTEXT);
NiceMock<MockScreen> serverScreen;
NiceMock<MockPrimaryClient> primaryClient;
NiceMock<MockConfig> serverConfig;
NiceMock<MockInputFilter> serverInputFilter;
-
+
m_events.adoptHandler(
m_events.forClientListener().connected(), &listener,
new TMethodEventJob<NetworkTests>(
@@ -128,7 +128,7 @@ TEST_F(NetworkTests, sendToClient_mockData)
ON_CALL(serverConfig, isScreen(_)).WillByDefault(Return(true));
ON_CALL(serverConfig, getInputFilter()).WillByDefault(Return(&serverInputFilter));
-
+
ServerArgs serverArgs;
serverArgs.m_enableDragDrop = true;
Server server(serverConfig, &primaryClient, &serverScreen, &m_events, serverArgs);
@@ -139,7 +139,7 @@ TEST_F(NetworkTests, sendToClient_mockData)
NiceMock<MockScreen> clientScreen;
SocketMultiplexer clientSocketMultiplexer;
TCPSocketFactory* clientSocketFactory = new TCPSocketFactory(&m_events, &clientSocketMultiplexer);
-
+
ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape));
ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos));
@@ -148,7 +148,7 @@ TEST_F(NetworkTests, sendToClient_mockData)
clientArgs.m_enableDragDrop = true;
clientArgs.m_enableCrypto = false;
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, clientArgs);
-
+
m_events.adoptHandler(
m_events.forFile().fileRecieveCompleted(), &client,
new TMethodEventJob<NetworkTests>(
@@ -169,16 +169,17 @@ TEST_F(NetworkTests, sendToClient_mockFile)
NetworkAddress serverAddress(TEST_HOST, TEST_PORT);
serverAddress.resolve();
-
+
// server
SocketMultiplexer serverSocketMultiplexer;
TCPSocketFactory* serverSocketFactory = new TCPSocketFactory(&m_events, &serverSocketMultiplexer);
- ClientListener listener(serverAddress, serverSocketFactory, &m_events, false);
+ ClientListener listener(serverAddress, serverSocketFactory, &m_events,
+ ConnectionSecurityLevel::PLAINTEXT);
NiceMock<MockScreen> serverScreen;
NiceMock<MockPrimaryClient> primaryClient;
NiceMock<MockConfig> serverConfig;
NiceMock<MockInputFilter> serverInputFilter;
-
+
m_events.adoptHandler(
m_events.forClientListener().connected(), &listener,
new TMethodEventJob<NetworkTests>(
@@ -186,7 +187,7 @@ TEST_F(NetworkTests, sendToClient_mockFile)
ON_CALL(serverConfig, isScreen(_)).WillByDefault(Return(true));
ON_CALL(serverConfig, getInputFilter()).WillByDefault(Return(&serverInputFilter));
-
+
ServerArgs serverArgs;
serverArgs.m_enableDragDrop = true;
Server server(serverConfig, &primaryClient, &serverScreen, &m_events, serverArgs);
@@ -197,7 +198,7 @@ TEST_F(NetworkTests, sendToClient_mockFile)
NiceMock<MockScreen> clientScreen;
SocketMultiplexer clientSocketMultiplexer;
TCPSocketFactory* clientSocketFactory = new TCPSocketFactory(&m_events, &clientSocketMultiplexer);
-
+
ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape));
ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos));
@@ -206,7 +207,7 @@ TEST_F(NetworkTests, sendToClient_mockFile)
clientArgs.m_enableDragDrop = true;
clientArgs.m_enableCrypto = false;
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, clientArgs);
-
+
m_events.adoptHandler(
m_events.forFile().fileRecieveCompleted(), &client,
new TMethodEventJob<NetworkTests>(
@@ -230,7 +231,8 @@ TEST_F(NetworkTests, sendToServer_mockData)
// server
SocketMultiplexer serverSocketMultiplexer;
TCPSocketFactory* serverSocketFactory = new TCPSocketFactory(&m_events, &serverSocketMultiplexer);
- ClientListener listener(serverAddress, serverSocketFactory, &m_events, false);
+ ClientListener listener(serverAddress, serverSocketFactory, &m_events,
+ ConnectionSecurityLevel::PLAINTEXT);
NiceMock<MockScreen> serverScreen;
NiceMock<MockPrimaryClient> primaryClient;
NiceMock<MockConfig> serverConfig;
@@ -238,7 +240,7 @@ TEST_F(NetworkTests, sendToServer_mockData)
ON_CALL(serverConfig, isScreen(_)).WillByDefault(Return(true));
ON_CALL(serverConfig, getInputFilter()).WillByDefault(Return(&serverInputFilter));
-
+
ServerArgs serverArgs;
serverArgs.m_enableDragDrop = true;
Server server(serverConfig, &primaryClient, &serverScreen, &m_events, serverArgs);
@@ -249,7 +251,7 @@ TEST_F(NetworkTests, sendToServer_mockData)
NiceMock<MockScreen> clientScreen;
SocketMultiplexer clientSocketMultiplexer;
TCPSocketFactory* clientSocketFactory = new TCPSocketFactory(&m_events, &clientSocketMultiplexer);
-
+
ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape));
ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos));
@@ -257,7 +259,7 @@ TEST_F(NetworkTests, sendToServer_mockData)
clientArgs.m_enableDragDrop = true;
clientArgs.m_enableCrypto = false;
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, clientArgs);
-
+
m_events.adoptHandler(
m_events.forClientListener().connected(), &listener,
new TMethodEventJob<NetworkTests>(
@@ -287,7 +289,8 @@ TEST_F(NetworkTests, sendToServer_mockFile)
// server
SocketMultiplexer serverSocketMultiplexer;
TCPSocketFactory* serverSocketFactory = new TCPSocketFactory(&m_events, &serverSocketMultiplexer);
- ClientListener listener(serverAddress, serverSocketFactory, &m_events, false);
+ ClientListener listener(serverAddress, serverSocketFactory, &m_events,
+ ConnectionSecurityLevel::PLAINTEXT);
NiceMock<MockScreen> serverScreen;
NiceMock<MockPrimaryClient> primaryClient;
NiceMock<MockConfig> serverConfig;
@@ -295,7 +298,7 @@ TEST_F(NetworkTests, sendToServer_mockFile)
ON_CALL(serverConfig, isScreen(_)).WillByDefault(Return(true));
ON_CALL(serverConfig, getInputFilter()).WillByDefault(Return(&serverInputFilter));
-
+
ServerArgs serverArgs;
serverArgs.m_enableDragDrop = true;
Server server(serverConfig, &primaryClient, &serverScreen, &m_events, serverArgs);
@@ -306,7 +309,7 @@ TEST_F(NetworkTests, sendToServer_mockFile)
NiceMock<MockScreen> clientScreen;
SocketMultiplexer clientSocketMultiplexer;
TCPSocketFactory* clientSocketFactory = new TCPSocketFactory(&m_events, &clientSocketMultiplexer);
-
+
ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape));
ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos));
@@ -334,7 +337,7 @@ TEST_F(NetworkTests, sendToServer_mockFile)
m_events.cleanupQuitTimeout();
}
-void
+void
NetworkTests::sendToClient_mockData_handleClientConnected(const Event&, void* vlistener)
{
ClientListener* listener = static_cast<ClientListener*>(vlistener);
@@ -352,7 +355,7 @@ NetworkTests::sendToClient_mockData_handleClientConnected(const Event&, void* vl
sendMockData(server);
}
-void
+void
NetworkTests::sendToClient_mockData_fileRecieveCompleted(const Event& event, void*)
{
Client* client = static_cast<Client*>(event.getTarget());
@@ -361,7 +364,7 @@ NetworkTests::sendToClient_mockData_fileRecieveCompleted(const Event& event, voi
m_events.raiseQuitEvent();
}
-void
+void
NetworkTests::sendToClient_mockFile_handleClientConnected(const Event&, void* vlistener)
{
ClientListener* listener = static_cast<ClientListener*>(vlistener);
@@ -379,7 +382,7 @@ NetworkTests::sendToClient_mockFile_handleClientConnected(const Event&, void* vl
server->sendFileToClient(kMockFilename);
}
-void
+void
NetworkTests::sendToClient_mockFile_fileRecieveCompleted(const Event& event, void*)
{
Client* client = static_cast<Client*>(event.getTarget());
@@ -388,14 +391,14 @@ NetworkTests::sendToClient_mockFile_fileRecieveCompleted(const Event& event, voi
m_events.raiseQuitEvent();
}
-void
+void
NetworkTests::sendToServer_mockData_handleClientConnected(const Event&, void* vclient)
{
Client* client = static_cast<Client*>(vclient);
sendMockData(client);
}
-void
+void
NetworkTests::sendToServer_mockData_fileRecieveCompleted(const Event& event, void*)
{
Server* server = static_cast<Server*>(event.getTarget());
@@ -404,14 +407,14 @@ NetworkTests::sendToServer_mockData_fileRecieveCompleted(const Event& event, voi
m_events.raiseQuitEvent();
}
-void
+void
NetworkTests::sendToServer_mockFile_handleClientConnected(const Event&, void* vclient)
{
Client* client = static_cast<Client*>(vclient);
client->sendFileToServer(kMockFilename);
}
-void
+void
NetworkTests::sendToServer_mockFile_fileRecieveCompleted(const Event& event, void*)
{
Server* server = static_cast<Server*>(event.getTarget());
@@ -420,13 +423,13 @@ NetworkTests::sendToServer_mockFile_fileRecieveCompleted(const Event& event, voi
m_events.raiseQuitEvent();
}
-void
+void
NetworkTests::sendMockData(void* eventTarget)
{
// send first message (file size)
String size = barrier::string::sizeTypeToString(kMockDataSize);
FileChunk* sizeMessage = FileChunk::start(size);
-
+
m_events.addEvent(Event(m_events.forFile().fileChunkSending(), eventTarget, sizeMessage));
// send chunk messages with incrementing chunk size
@@ -452,7 +455,7 @@ NetworkTests::sendMockData(void* eventTarget)
}
}
-
+
// send last message
FileChunk* transferFinished = FileChunk::end();
m_events.addEvent(Event(m_events.forFile().fileChunkSending(), eventTarget, transferFinished));
diff --git a/src/test/integtests/platform/MSWindowsClipboardTests.cpp b/src/test/integtests/platform/MSWindowsClipboardTests.cpp
index f9d09d1..edf5a97 100644
--- a/src/test/integtests/platform/MSWindowsClipboardTests.cpp
+++ b/src/test/integtests/platform/MSWindowsClipboardTests.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2011 Nick Bolton
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -36,7 +36,7 @@ protected:
}
private:
- void emptyClipboard()
+ void emptyClipboard()
{
MSWindowsClipboard clipboard(NULL);
clipboard.open(0);
diff --git a/src/test/integtests/platform/MSWindowsKeyStateTests.cpp b/src/test/integtests/platform/MSWindowsKeyStateTests.cpp
index 9373d14..6f6edf5 100644
--- a/src/test/integtests/platform/MSWindowsKeyStateTests.cpp
+++ b/src/test/integtests/platform/MSWindowsKeyStateTests.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2011 Nick Bolton
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#define TEST_ENV
+#define BARRIER_TEST_ENV
#include "test/mock/barrier/MockEventQueue.h"
#include "test/mock/barrier/MockKeyMap.h"
@@ -24,7 +24,6 @@
#include "platform/MSWindowsDesks.h"
#include "platform/MSWindowsScreen.h"
#include "platform/MSWindowsScreenSaver.h"
-#include "base/TMethodJob.h"
#include "test/global/gtest.h"
#include "test/global/gmock.h"
@@ -50,10 +49,7 @@ protected:
MSWindowsDesks* newDesks(IEventQueue* eventQueue)
{
- return new MSWindowsDesks(
- true, false, m_screensaver, eventQueue,
- new TMethodJob<MSWindowsKeyStateTests>(
- this, &MSWindowsKeyStateTests::updateKeysCB), false);
+ return new MSWindowsDesks(true, false, m_screensaver, eventQueue, [](){}, false);
}
void* getEventTarget() const
@@ -62,9 +58,7 @@ protected:
}
private:
- void updateKeysCB(void*) { }
IScreenSaver* m_screensaver;
- MSWindowsHook m_hook;
};
TEST_F(MSWindowsKeyStateTests, disable_eventQueueNotUsed)
@@ -73,7 +67,7 @@ TEST_F(MSWindowsKeyStateTests, disable_eventQueueNotUsed)
MSWindowsDesks* desks = newDesks(&eventQueue);
MockKeyMap keyMap;
MSWindowsKeyState keyState(desks, getEventTarget(), &eventQueue, keyMap);
-
+
EXPECT_CALL(eventQueue, removeHandler(_, _)).Times(0);
keyState.disable();
diff --git a/src/test/integtests/platform/OSXClipboardTests.cpp b/src/test/integtests/platform/OSXClipboardTests.cpp
index 45b73bd..093c738 100644
--- a/src/test/integtests/platform/OSXClipboardTests.cpp
+++ b/src/test/integtests/platform/OSXClipboardTests.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2011 Nick Bolton
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -25,9 +25,9 @@ TEST(OSXClipboardTests, empty_openCalled_returnsTrue)
{
OSXClipboard clipboard;
clipboard.open(0);
-
+
bool actual = clipboard.empty();
-
+
EXPECT_EQ(true, actual);
}
@@ -36,9 +36,9 @@ TEST(OSXClipboardTests, empty_singleFormat_hasReturnsFalse)
OSXClipboard clipboard;
clipboard.open(0);
clipboard.add(OSXClipboard::kText, "barrier rocks!");
-
+
clipboard.empty();
-
+
bool actual = clipboard.has(OSXClipboard::kText);
EXPECT_EQ(false, actual);
}
@@ -47,9 +47,9 @@ TEST(OSXClipboardTests, add_newValue_valueWasStored)
{
OSXClipboard clipboard;
clipboard.open(0);
-
+
clipboard.add(IClipboard::kText, "barrier rocks!");
-
+
String actual = clipboard.get(IClipboard::kText);
EXPECT_EQ("barrier rocks!", actual);
}
@@ -58,10 +58,10 @@ TEST(OSXClipboardTests, add_replaceValue_valueWasReplaced)
{
OSXClipboard clipboard;
clipboard.open(0);
-
+
clipboard.add(IClipboard::kText, "barrier rocks!");
clipboard.add(IClipboard::kText, "maxivista sucks"); // haha, just kidding.
-
+
String actual = clipboard.get(IClipboard::kText);
EXPECT_EQ("maxivista sucks", actual);
}
@@ -69,18 +69,18 @@ TEST(OSXClipboardTests, add_replaceValue_valueWasReplaced)
TEST(OSXClipboardTests, open_timeIsZero_returnsTrue)
{
OSXClipboard clipboard;
-
+
bool actual = clipboard.open(0);
-
+
EXPECT_EQ(true, actual);
}
TEST(OSXClipboardTests, open_timeIsOne_returnsTrue)
{
OSXClipboard clipboard;
-
+
bool actual = clipboard.open(1);
-
+
EXPECT_EQ(true, actual);
}
@@ -88,9 +88,9 @@ TEST(OSXClipboardTests, close_isOpen_noErrors)
{
OSXClipboard clipboard;
clipboard.open(0);
-
+
clipboard.close();
-
+
// can't assert anything
}
@@ -98,9 +98,9 @@ TEST(OSXClipboardTests, getTime_openWithNoEmpty_returnsOne)
{
OSXClipboard clipboard;
clipboard.open(1);
-
+
OSXClipboard::Time actual = clipboard.getTime();
-
+
// this behavior is different to that of Clipboard which only
// returns the value passed into open(t) after empty() is called.
EXPECT_EQ((UInt32)1, actual);
@@ -111,9 +111,9 @@ TEST(OSXClipboardTests, getTime_openAndEmpty_returnsOne)
OSXClipboard clipboard;
clipboard.open(1);
clipboard.empty();
-
+
OSXClipboard::Time actual = clipboard.getTime();
-
+
EXPECT_EQ((UInt32)1, actual);
}
@@ -123,9 +123,9 @@ TEST(OSXClipboardTests, has_withFormatAdded_returnsTrue)
clipboard.open(0);
clipboard.empty();
clipboard.add(IClipboard::kText, "barrier rocks!");
-
+
bool actual = clipboard.has(IClipboard::kText);
-
+
EXPECT_EQ(true, actual);
}
@@ -134,9 +134,9 @@ TEST(OSXClipboardTests, has_withNoFormats_returnsFalse)
OSXClipboard clipboard;
clipboard.open(0);
clipboard.empty();
-
+
bool actual = clipboard.has(IClipboard::kText);
-
+
EXPECT_EQ(false, actual);
}
@@ -145,9 +145,9 @@ TEST(OSXClipboardTests, get_withNoFormats_returnsEmpty)
OSXClipboard clipboard;
clipboard.open(0);
clipboard.empty();
-
+
String actual = clipboard.get(IClipboard::kText);
-
+
EXPECT_EQ("", actual);
}
@@ -157,8 +157,8 @@ TEST(OSXClipboardTests, get_withFormatAdded_returnsExpected)
clipboard.open(0);
clipboard.empty();
clipboard.add(IClipboard::kText, "barrier rocks!");
-
+
String actual = clipboard.get(IClipboard::kText);
-
+
EXPECT_EQ("barrier rocks!", actual);
}
diff --git a/src/test/integtests/platform/OSXScreenTests.cpp b/src/test/integtests/platform/OSXScreenTests.cpp
index 96beb4d..390e22f 100644
--- a/src/test/integtests/platform/OSXScreenTests.cpp
+++ b/src/test/integtests/platform/OSXScreenTests.cpp
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/test/integtests/platform/XWindowsClipboardTests.cpp b/src/test/integtests/platform/XWindowsClipboardTests.cpp
index 652ee5e..52eacda 100644
--- a/src/test/integtests/platform/XWindowsClipboardTests.cpp
+++ b/src/test/integtests/platform/XWindowsClipboardTests.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2011 Nick Bolton
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -33,12 +33,12 @@ protected:
m_display = XOpenDisplay(NULL);
int screen = DefaultScreen(m_display);
Window root = XRootWindow(m_display, screen);
-
+
XSetWindowAttributes attr;
attr.do_not_propagate_mask = 0;
attr.override_redirect = True;
attr.cursor = Cursor();
-
+
m_window = XCreateWindow(
m_display, root, 0, 0, 1, 1, 0, 0,
InputOnly, CopyFromParent, 0, &attr);
@@ -68,9 +68,9 @@ protected:
TEST_F(CXWindowsClipboardTests, empty_openCalled_returnsTrue)
{
CXWindowsClipboard clipboard = createClipboard();
-
+
bool actual = clipboard.empty();
-
+
EXPECT_EQ(true, actual);
}
@@ -78,9 +78,9 @@ TEST_F(CXWindowsClipboardTests, empty_singleFormat_hasReturnsFalse)
{
CXWindowsClipboard clipboard = createClipboard();
clipboard.add(CXWindowsClipboard::kText, "barrier rocks!");
-
+
clipboard.empty();
-
+
bool actual = clipboard.has(CXWindowsClipboard::kText);
EXPECT_FALSE(actual);
}
@@ -88,9 +88,9 @@ TEST_F(CXWindowsClipboardTests, empty_singleFormat_hasReturnsFalse)
TEST_F(CXWindowsClipboardTests, add_newValue_valueWasStored)
{
CXWindowsClipboard clipboard = createClipboard();
-
+
clipboard.add(IClipboard::kText, "barrier rocks!");
-
+
String actual = clipboard.get(IClipboard::kText);
EXPECT_EQ("barrier rocks!", actual);
}
@@ -98,10 +98,10 @@ TEST_F(CXWindowsClipboardTests, add_newValue_valueWasStored)
TEST_F(CXWindowsClipboardTests, add_replaceValue_valueWasReplaced)
{
CXWindowsClipboard clipboard = createClipboard();
-
+
clipboard.add(IClipboard::kText, "barrier rocks!");
clipboard.add(IClipboard::kText, "maxivista sucks"); // haha, just kidding.
-
+
String actual = clipboard.get(IClipboard::kText);
EXPECT_EQ("maxivista sucks", actual);
}
@@ -109,10 +109,10 @@ TEST_F(CXWindowsClipboardTests, add_replaceValue_valueWasReplaced)
TEST_F(CXWindowsClipboardTests, close_isOpen_noErrors)
{
CXWindowsClipboard clipboard = createClipboard();
-
+
// clipboard opened in createClipboard()
clipboard.close();
-
+
// can't assert anything
}
@@ -120,27 +120,27 @@ TEST_F(CXWindowsClipboardTests, has_withFormatAdded_returnsTrue)
{
CXWindowsClipboard clipboard = createClipboard();
clipboard.add(IClipboard::kText, "barrier rocks!");
-
+
bool actual = clipboard.has(IClipboard::kText);
-
+
EXPECT_EQ(true, actual);
}
TEST_F(CXWindowsClipboardTests, has_withNoFormats_returnsFalse)
{
CXWindowsClipboard clipboard = createClipboard();
-
+
bool actual = clipboard.has(IClipboard::kText);
-
+
EXPECT_FALSE(actual);
}
TEST_F(CXWindowsClipboardTests, get_withNoFormats_returnsEmpty)
{
CXWindowsClipboard clipboard = createClipboard();
-
+
String actual = clipboard.get(IClipboard::kText);
-
+
EXPECT_EQ("", actual);
}
@@ -148,9 +148,9 @@ TEST_F(CXWindowsClipboardTests, get_withFormatAdded_returnsExpected)
{
CXWindowsClipboard clipboard = createClipboard();
clipboard.add(IClipboard::kText, "barrier rocks!");
-
+
String actual = clipboard.get(IClipboard::kText);
-
+
EXPECT_EQ("barrier rocks!", actual);
}
diff --git a/src/test/integtests/platform/XWindowsKeyStateTests.cpp b/src/test/integtests/platform/XWindowsKeyStateTests.cpp
index 9f6716d..28d090f 100644
--- a/src/test/integtests/platform/XWindowsKeyStateTests.cpp
+++ b/src/test/integtests/platform/XWindowsKeyStateTests.cpp
@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#define TEST_ENV
+#define BARRIER_TEST_ENV
#include "test/mock/barrier/MockKeyMap.h"
#include "test/mock/barrier/MockEventQueue.h"
diff --git a/src/test/integtests/platform/XWindowsScreenSaverTests.cpp b/src/test/integtests/platform/XWindowsScreenSaverTests.cpp
index c6a2710..a3af21d 100644
--- a/src/test/integtests/platform/XWindowsScreenSaverTests.cpp
+++ b/src/test/integtests/platform/XWindowsScreenSaverTests.cpp
@@ -23,6 +23,7 @@
#include "platform/XWindowsScreenSaver.h"
#include "test/global/gtest.h"
+#include <cstdlib>
#include <X11/Xlib.h>
using ::testing::_;
@@ -30,7 +31,12 @@ using ::testing::_;
// TODO: not working on build machine for some reason
TEST(CXWindowsScreenSaverTests, activate_defaultScreen_todo)
{
- Display* display = XOpenDisplay(":0.0");
+ const char* displayName = std::getenv("DISPLAY");
+ if (displayName == NULL) {
+ displayName = ":0.0";
+ }
+
+ Display* display = XOpenDisplay(displayName);
Window window = DefaultRootWindow(display);
MockEventQueue eventQueue;
EXPECT_CALL(eventQueue, removeHandler(_, _)).Times(1);
diff --git a/src/test/integtests/platform/XWindowsScreenTests.cpp b/src/test/integtests/platform/XWindowsScreenTests.cpp
index d8f75e1..53f113e 100644
--- a/src/test/integtests/platform/XWindowsScreenTests.cpp
+++ b/src/test/integtests/platform/XWindowsScreenTests.cpp
@@ -20,16 +20,22 @@
#include "platform/XWindowsScreen.h"
#include "test/global/gtest.h"
+#include <cstdlib>
using ::testing::_;
TEST(CXWindowsScreenTests, fakeMouseMove_nonPrimary_getCursorPosValuesCorrect)
{
+ const char* displayName = std::getenv("DISPLAY");
+ if (displayName == NULL) {
+ displayName = ":0.0";
+ }
+
MockEventQueue eventQueue;
EXPECT_CALL(eventQueue, adoptHandler(_, _, _)).Times(2);
EXPECT_CALL(eventQueue, adoptBuffer(_)).Times(2);
EXPECT_CALL(eventQueue, removeHandler(_, _)).Times(2);
- XWindowsScreen screen(new XWindowsImpl(), ":0.0", false, false, 0, &eventQueue);
+ XWindowsScreen screen(new XWindowsImpl(), displayName, false, false, 0, &eventQueue);
screen.fakeMouseMove(10, 20);
diff --git a/src/test/mock/barrier/MockApp.h b/src/test/mock/barrier/MockApp.h
index 91745d3..fd4094d 100644
--- a/src/test/mock/barrier/MockApp.h
+++ b/src/test/mock/barrier/MockApp.h
@@ -17,7 +17,7 @@
#pragma once
-#define TEST_ENV
+#define BARRIER_TEST_ENV
#include "barrier/App.h"
diff --git a/src/test/mock/barrier/MockArgParser.h b/src/test/mock/barrier/MockArgParser.h
index b1dc07c..35d4ff9 100644
--- a/src/test/mock/barrier/MockArgParser.h
+++ b/src/test/mock/barrier/MockArgParser.h
@@ -17,7 +17,7 @@
#pragma once
-#define TEST_ENV
+#define BARRIER_TEST_ENV
#include "barrier/ArgParser.h"
diff --git a/src/test/mock/barrier/MockEventQueue.h b/src/test/mock/barrier/MockEventQueue.h
index 735b9fc..76175bb 100644
--- a/src/test/mock/barrier/MockEventQueue.h
+++ b/src/test/mock/barrier/MockEventQueue.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2011 Nick Bolton
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/test/mock/barrier/MockKeyState.h b/src/test/mock/barrier/MockKeyState.h
index 308e90a..d245ee6 100644
--- a/src/test/mock/barrier/MockKeyState.h
+++ b/src/test/mock/barrier/MockKeyState.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2011 Nick Bolton
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/test/mock/barrier/MockScreen.h b/src/test/mock/barrier/MockScreen.h
index 78c195a..3c05218 100644
--- a/src/test/mock/barrier/MockScreen.h
+++ b/src/test/mock/barrier/MockScreen.h
@@ -17,7 +17,7 @@
#pragma once
-#define TEST_ENV
+#define BARRIER_TEST_ENV
#include "barrier/Screen.h"
diff --git a/src/test/mock/ipc/MockIpcServer.h b/src/test/mock/ipc/MockIpcServer.h
index 4124b41..5b09b39 100644
--- a/src/test/mock/ipc/MockIpcServer.h
+++ b/src/test/mock/ipc/MockIpcServer.h
@@ -34,7 +34,7 @@ public:
MockIpcServer() :
m_sendCond(ARCH->newCondVar()),
m_sendMutex(ARCH->newMutex()) { }
-
+
~MockIpcServer() {
if (m_sendCond != NULL) {
ARCH->closeCondVar(m_sendCond);
diff --git a/src/test/mock/server/MockConfig.h b/src/test/mock/server/MockConfig.h
index 4161de0..c0b40dc 100644
--- a/src/test/mock/server/MockConfig.h
+++ b/src/test/mock/server/MockConfig.h
@@ -17,7 +17,7 @@
#pragma once
-#define TEST_ENV
+#define BARRIER_TEST_ENV
#include "server/Config.h"
diff --git a/src/test/mock/server/MockInputFilter.h b/src/test/mock/server/MockInputFilter.h
index edf6de1..09aeee2 100644
--- a/src/test/mock/server/MockInputFilter.h
+++ b/src/test/mock/server/MockInputFilter.h
@@ -17,7 +17,7 @@
#pragma once
-#define TEST_ENV
+#define BARRIER_TEST_ENV
#include "server/InputFilter.h"
diff --git a/src/test/mock/server/MockPrimaryClient.h b/src/test/mock/server/MockPrimaryClient.h
index 80f18a1..db76187 100644
--- a/src/test/mock/server/MockPrimaryClient.h
+++ b/src/test/mock/server/MockPrimaryClient.h
@@ -17,7 +17,7 @@
#pragma once
-#define TEST_ENV
+#define BARRIER_TEST_ENV
#include "server/PrimaryClient.h"
#include "base/String.h"
diff --git a/src/test/mock/server/MockServer.h b/src/test/mock/server/MockServer.h
index a45ee08..74ad1d0 100644
--- a/src/test/mock/server/MockServer.h
+++ b/src/test/mock/server/MockServer.h
@@ -17,7 +17,7 @@
#pragma once
-#define TEST_ENV
+#define BARRIER_TEST_ENV
#include "server/Server.h"
diff --git a/src/test/unittests/CMakeLists.txt b/src/test/unittests/CMakeLists.txt
index c46375c..8cf5e9a 100644
--- a/src/test/unittests/CMakeLists.txt
+++ b/src/test/unittests/CMakeLists.txt
@@ -1,11 +1,11 @@
# barrier -- mouse and keyboard sharing utility
# Copyright (C) 2012-2016 Symless Ltd.
# Copyright (C) 2009 Nick Bolton
-#
+#
# This package is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# found in the file LICENSE that should have accompanied this file.
-#
+#
# This package is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -50,8 +50,6 @@ list(APPEND headers ${platform_sources})
include_directories(
../../
- ../../../ext/gtest/include
- ../../../ext/gmock/include
../../../ext
)
@@ -67,4 +65,4 @@ endif()
add_executable(unittests ${sources})
target_link_libraries(unittests
- arch base client server common io net platform server synlib mt ipc gtest gmock ${libs} ${OPENSSL_LIBS})
+ arch base client server common io net platform server synlib mt ipc ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} ${libs} ${OPENSSL_LIBS})
diff --git a/src/test/unittests/Main.cpp b/src/test/unittests/Main.cpp
index 7f0d0fe..52ad252 100644
--- a/src/test/unittests/Main.cpp
+++ b/src/test/unittests/Main.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2011 Nick Bolton
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -35,12 +35,12 @@ main(int argc, char **argv)
Arch arch;
arch.init();
-
+
Log log;
log.setFilter(kDEBUG4);
testing::InitGoogleTest(&argc, argv);
-
+
// gtest seems to randomly finish with error codes (e.g. -1, -1073741819)
// even when no tests have failed. not sure what causes this, but it
// happens on all platforms and keeps leading to false positives.
diff --git a/src/test/unittests/barrier/ArgParserTests.cpp b/src/test/unittests/barrier/ArgParserTests.cpp
index e14877e..311162f 100644
--- a/src/test/unittests/barrier/ArgParserTests.cpp
+++ b/src/test/unittests/barrier/ArgParserTests.cpp
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2014-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/test/unittests/barrier/ClientArgsParsingTests.cpp b/src/test/unittests/barrier/ClientArgsParsingTests.cpp
index 5a1e7d0..7aaa5db 100644
--- a/src/test/unittests/barrier/ClientArgsParsingTests.cpp
+++ b/src/test/unittests/barrier/ClientArgsParsingTests.cpp
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2014-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/test/unittests/barrier/ClipboardChunkTests.cpp b/src/test/unittests/barrier/ClipboardChunkTests.cpp
index e0e37be..784dee8 100644
--- a/src/test/unittests/barrier/ClipboardChunkTests.cpp
+++ b/src/test/unittests/barrier/ClipboardChunkTests.cpp
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2015-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/test/unittests/barrier/ClipboardTests.cpp b/src/test/unittests/barrier/ClipboardTests.cpp
index f710751..c1afdfb 100644
--- a/src/test/unittests/barrier/ClipboardTests.cpp
+++ b/src/test/unittests/barrier/ClipboardTests.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2011 Nick Bolton
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -192,7 +192,7 @@ TEST(ClipboardTests, marshall_withTextAdded_lastSizeCharIs14)
EXPECT_EQ(14, (int)actual[11]);
}
-// TODO: there's some integer -> char encoding going on here. i find it
+// TODO: there's some integer -> char encoding going on here. i find it
// hard to believe that the clipboard is the only thing doing this. maybe
// we should refactor this stuff out of the clipboard.
TEST(ClipboardTests, marshall_withTextSize285_sizeCharsValid)
@@ -212,12 +212,12 @@ TEST(ClipboardTests, marshall_withTextSize285_sizeCharsValid)
String actual = clipboard.marshall();
- // 4 asserts here, but that's ok because we're really just asserting 1
+ // 4 asserts here, but that's ok because we're really just asserting 1
// thing. the 32-bit size value is split into 4 chars. if the size is 285
- // (29 more than the 8-bit max size), the last char "rolls over" to 29
- // (this is caused by a bit-wise & on 0xff and 8-bit truncation). each
- // char before the last stores a bit-shifted version of the number, each
- // 1 more power than the last, which is done by bit-shifting [0] by 24,
+ // (29 more than the 8-bit max size), the last char "rolls over" to 29
+ // (this is caused by a bit-wise & on 0xff and 8-bit truncation). each
+ // char before the last stores a bit-shifted version of the number, each
+ // 1 more power than the last, which is done by bit-shifting [0] by 24,
// [1] by 16, [2] by 8 ([3] is not bit-shifted).
EXPECT_EQ(0, actual[8]); // 285 >> 24 = 285 / (256^3) = 0
EXPECT_EQ(0, actual[9]); // 285 >> 16 = 285 / (256^2) = 0
diff --git a/src/test/unittests/barrier/GenericArgsParsingTests.cpp b/src/test/unittests/barrier/GenericArgsParsingTests.cpp
index f43070b..7f19918 100644
--- a/src/test/unittests/barrier/GenericArgsParsingTests.cpp
+++ b/src/test/unittests/barrier/GenericArgsParsingTests.cpp
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2014-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -50,7 +50,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_logLevelCmd_setLogLevel)
ArgParser argParser(NULL);
ArgsBase argsBase;
argParser.setArgsBase(argsBase);
-
+
argParser.parseGenericArgs(argc, kLogLevelCmd, i);
String logFilter(argsBase.m_logFilter);
@@ -68,7 +68,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_logFileCmd_saveLogFilename)
ArgParser argParser(NULL);
ArgsBase argsBase;
argParser.setArgsBase(argsBase);
-
+
argParser.parseGenericArgs(argc, kLogFileCmd, i);
String logFile(argsBase.m_logFile);
@@ -86,7 +86,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_logFileCmdWithSpace_saveLogFilena
ArgParser argParser(NULL);
ArgsBase argsBase;
argParser.setArgsBase(argsBase);
-
+
argParser.parseGenericArgs(argc, kLogFileCmdWithSpace, i);
String logFile(argsBase.m_logFile);
@@ -104,7 +104,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_noDeamonCmd_daemonFalse)
ArgParser argParser(NULL);
ArgsBase argsBase;
argParser.setArgsBase(argsBase);
-
+
argParser.parseGenericArgs(argc, kNoDeamonCmd, i);
EXPECT_FALSE(argsBase.m_daemon);
@@ -120,7 +120,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_deamonCmd_daemonTrue)
ArgParser argParser(NULL);
ArgsBase argsBase;
argParser.setArgsBase(argsBase);
-
+
argParser.parseGenericArgs(argc, kDeamonCmd, i);
EXPECT_EQ(true, argsBase.m_daemon);
@@ -136,7 +136,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_nameCmd_saveName)
ArgParser argParser(NULL);
ArgsBase argsBase;
argParser.setArgsBase(argsBase);
-
+
argParser.parseGenericArgs(argc, kNameCmd, i);
EXPECT_EQ("mock", argsBase.m_name);
@@ -152,7 +152,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_noRestartCmd_restartFalse)
ArgParser argParser(NULL);
ArgsBase argsBase;
argParser.setArgsBase(argsBase);
-
+
argParser.parseGenericArgs(argc, kNoRestartCmd, i);
EXPECT_FALSE(argsBase.m_restartable);
@@ -168,7 +168,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_restartCmd_restartTrue)
ArgParser argParser(NULL);
ArgsBase argsBase;
argParser.setArgsBase(argsBase);
-
+
argParser.parseGenericArgs(argc, kRestartCmd, i);
EXPECT_EQ(true, argsBase.m_restartable);
@@ -184,7 +184,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_backendCmd_backendTrue)
ArgParser argParser(NULL);
ArgsBase argsBase;
argParser.setArgsBase(argsBase);
-
+
argParser.parseGenericArgs(argc, kBackendCmd, i);
EXPECT_EQ(true, argsBase.m_backend);
@@ -200,7 +200,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_noHookCmd_noHookTrue)
ArgParser argParser(NULL);
ArgsBase argsBase;
argParser.setArgsBase(argsBase);
-
+
argParser.parseGenericArgs(argc, kNoHookCmd, i);
EXPECT_EQ(true, argsBase.m_noHooks);
@@ -219,7 +219,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_helpCmd_showHelp)
ArgsBase argsBase;
argParser.setArgsBase(argsBase);
ON_CALL(app, help()).WillByDefault(Invoke(showMockHelp));
-
+
argParser.parseGenericArgs(argc, kHelpCmd, i);
EXPECT_EQ(true, g_helpShowed);
@@ -239,7 +239,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_versionCmd_showVersion)
ArgsBase argsBase;
argParser.setArgsBase(argsBase);
ON_CALL(app, version()).WillByDefault(Invoke(showMockVersion));
-
+
argParser.parseGenericArgs(argc, kVersionCmd, i);
EXPECT_EQ(true, g_versionShowed);
@@ -255,7 +255,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_noTrayCmd_disableTrayTrue)
ArgParser argParser(NULL);
ArgsBase argsBase;
argParser.setArgsBase(argsBase);
-
+
argParser.parseGenericArgs(argc, kNoTrayCmd, i);
EXPECT_EQ(true, argsBase.m_disableTray);
@@ -271,7 +271,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_ipcCmd_enableIpcTrue)
ArgParser argParser(NULL);
ArgsBase argsBase;
argParser.setArgsBase(argsBase);
-
+
argParser.parseGenericArgs(argc, kIpcCmd, i);
EXPECT_EQ(true, argsBase.m_enableIpc);
@@ -288,7 +288,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_dragDropCmdOnNonLinux_enableDragD
ArgParser argParser(NULL);
ArgsBase argsBase;
argParser.setArgsBase(argsBase);
-
+
argParser.parseGenericArgs(argc, kDragDropCmd, i);
EXPECT_EQ(true, argsBase.m_enableDragDrop);
@@ -306,7 +306,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_dragDropCmdOnLinux_enableDragDrop
ArgParser argParser(NULL);
ArgsBase argsBase;
argParser.setArgsBase(argsBase);
-
+
argParser.parseGenericArgs(argc, kDragDropCmd, i);
EXPECT_FALSE(argsBase.m_enableDragDrop);
diff --git a/src/test/unittests/barrier/KeyMapTests.cpp b/src/test/unittests/barrier/KeyMapTests.cpp
index 5980633..20c1c55 100644
--- a/src/test/unittests/barrier/KeyMapTests.cpp
+++ b/src/test/unittests/barrier/KeyMapTests.cpp
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2016 Symless
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -15,6 +15,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#define BARRIER_TEST_ENV
+
#include "barrier/KeyMap.h"
#include "test/global/gtest.h"
@@ -28,7 +30,7 @@ using ::testing::ReturnRef;
using ::testing::SaveArg;
namespace barrier {
-
+
TEST(KeyMapTests, findBestKey_requiredDown_matchExactFirstItem)
{
KeyMap keyMap;
@@ -44,7 +46,7 @@ TEST(KeyMapTests, findBestKey_requiredDown_matchExactFirstItem)
EXPECT_EQ(0, keyMap.findBestKey(entryList, currentState, desiredState));
}
-
+
TEST(KeyMapTests, findBestKey_requiredAndExtraSensitiveDown_matchExactFirstItem)
{
KeyMap keyMap;
@@ -82,7 +84,7 @@ TEST(KeyMapTests, findBestKey_requiredAndExtraSensitiveDown_matchExactSecondItem
EXPECT_EQ(1, keyMap.findBestKey(entryList, currentState, desiredState));
}
-
+
TEST(KeyMapTests, findBestKey_extraSensitiveDown_matchExactSecondItem)
{
KeyMap keyMap;
@@ -101,7 +103,7 @@ TEST(KeyMapTests, findBestKey_extraSensitiveDown_matchExactSecondItem)
itemList2.push_back(item2);
entryList.push_back(itemList1);
entryList.push_back(itemList2);
-
+
EXPECT_EQ(1, keyMap.findBestKey(entryList, currentState, desiredState));
}
@@ -123,7 +125,7 @@ TEST(KeyMapTests, findBestKey_noRequiredDown_matchOneRequiredChangeItem)
itemList2.push_back(item2);
entryList.push_back(itemList1);
entryList.push_back(itemList2);
-
+
EXPECT_EQ(1, keyMap.findBestKey(entryList, currentState, desiredState));
}
@@ -148,7 +150,7 @@ TEST(KeyMapTests, findBestKey_onlyOneRequiredDown_matchTwoRequiredChangesItem)
EXPECT_EQ(1, keyMap.findBestKey(entryList, currentState, desiredState));
}
-
+
TEST(KeyMapTests, findBestKey_noRequiredDown_cannotMatch)
{
KeyMap keyMap;
@@ -161,31 +163,31 @@ TEST(KeyMapTests, findBestKey_noRequiredDown_cannotMatch)
KeyModifierMask desiredState = 0;
itemList.push_back(item);
entryList.push_back(itemList);
-
+
EXPECT_EQ(-1, keyMap.findBestKey(entryList, currentState, desiredState));
}
-
+
TEST(KeyMapTests, isCommand_shiftMask_returnFalse)
{
KeyMap keyMap;
KeyModifierMask mask= KeyModifierShift;
-
+
EXPECT_FALSE(keyMap.isCommand(mask));
}
-
+
TEST(KeyMapTests, isCommand_controlMask_returnTrue)
{
KeyMap keyMap;
KeyModifierMask mask= KeyModifierControl;
-
+
EXPECT_EQ(true, keyMap.isCommand(mask));
}
-
+
TEST(KeyMapTests, isCommand_alternateMask_returnTrue)
{
KeyMap keyMap;
KeyModifierMask mask= KeyModifierAlt;
-
+
EXPECT_EQ(true, keyMap.isCommand(mask));
}
@@ -193,15 +195,15 @@ TEST(KeyMapTests, isCommand_alternateGraphicMask_returnTrue)
{
KeyMap keyMap;
KeyModifierMask mask= KeyModifierAltGr;
-
+
EXPECT_EQ(true, keyMap.isCommand(mask));
}
-
+
TEST(KeyMapTests, isCommand_metaMask_returnTrue)
{
KeyMap keyMap;
KeyModifierMask mask= KeyModifierMeta;
-
+
EXPECT_EQ(true, keyMap.isCommand(mask));
}
@@ -209,8 +211,8 @@ TEST(KeyMapTests, isCommand_superMask_returnTrue)
{
KeyMap keyMap;
KeyModifierMask mask= KeyModifierSuper;
-
+
EXPECT_EQ(true, keyMap.isCommand(mask));
}
-
+
}
diff --git a/src/test/unittests/barrier/KeyStateTests.cpp b/src/test/unittests/barrier/KeyStateTests.cpp
index d4154d8..bc41933 100644
--- a/src/test/unittests/barrier/KeyStateTests.cpp
+++ b/src/test/unittests/barrier/KeyStateTests.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2011 Nick Bolton
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -100,7 +100,7 @@ TEST(KeyStateTests, sendKeyEvent_halfDuplex_addEventCalledTwice)
KeyStateImpl keyState(eventQueue, keyMap);
IKeyStateEvents keyStateEvents;
keyStateEvents.setEvents(&eventQueue);
-
+
ON_CALL(keyMap, isHalfDuplex(_, _)).WillByDefault(Return(true));
ON_CALL(eventQueue, forIKeyState()).WillByDefault(ReturnRef(keyStateEvents));
@@ -116,7 +116,7 @@ TEST(KeyStateTests, sendKeyEvent_keyRepeat_addEventCalledOnce)
KeyStateImpl keyState(eventQueue, keyMap);
IKeyStateEvents keyStateEvents;
keyStateEvents.setEvents(&eventQueue);
-
+
ON_CALL(eventQueue, forIKeyState()).WillByDefault(ReturnRef(keyStateEvents));
EXPECT_CALL(eventQueue, addEvent(_)).Times(1);
@@ -131,7 +131,7 @@ TEST(KeyStateTests, sendKeyEvent_keyDown_addEventCalledOnce)
KeyStateImpl keyState(eventQueue, keyMap);
IKeyStateEvents keyStateEvents;
keyStateEvents.setEvents(&eventQueue);
-
+
ON_CALL(eventQueue, forIKeyState()).WillByDefault(ReturnRef(keyStateEvents));
EXPECT_CALL(eventQueue, addEvent(_)).Times(1);
@@ -146,7 +146,7 @@ TEST(KeyStateTests, sendKeyEvent_keyUp_addEventCalledOnce)
KeyStateImpl keyState(eventQueue, keyMap);
IKeyStateEvents keyStateEvents;
keyStateEvents.setEvents(&eventQueue);
-
+
ON_CALL(eventQueue, forIKeyState()).WillByDefault(ReturnRef(keyStateEvents));
EXPECT_CALL(eventQueue, addEvent(_)).Times(1);
diff --git a/src/test/unittests/base/StringTests.cpp b/src/test/unittests/base/StringTests.cpp
index 39ad6e8..cc8e4fc 100644
--- a/src/test/unittests/base/StringTests.cpp
+++ b/src/test/unittests/base/StringTests.cpp
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2014-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -56,12 +56,38 @@ TEST(StringTests, sprintf_formatWithArgument_formatedString)
TEST(StringTests, toHex_plaintext_hexString)
{
- String subject = "foobar";
+ std::vector<std::uint8_t> subject{'f', 'o', 'o', 'b', 'a', 'r'};
int width = 2;
- string::toHex(subject, width);
+ EXPECT_EQ("666f6f626172", string::to_hex(subject, width));
+}
+
+TEST(StringTests, fromhex_plaintext_string)
+{
+ auto result = string::from_hex("666f6f626172");
+ std::string expected = "foobar";
+ EXPECT_EQ(result, std::vector<std::uint8_t>(expected.begin(), expected.end()));
+}
+
+TEST(StringTests, fromhex_plaintext_string_colons)
+{
+ auto result = string::from_hex("66:6f:6f:62:61:72");
+ std::string expected = "foobar";
+ EXPECT_EQ(result, std::vector<std::uint8_t>(expected.begin(), expected.end()));
+}
- EXPECT_EQ("666f6f626172", subject);
+TEST(StringTests, fromhex_binary_string)
+{
+ auto result = string::from_hex("01020304050600fff9");
+ auto expected = std::vector<std::uint8_t>{1, 2, 3, 4, 5, 6, 0, 0xff, 0xf9};
+ EXPECT_EQ(result, expected);
+}
+
+TEST(StringTests, fromhex_invalid_string)
+{
+ EXPECT_TRUE(string::from_hex("66:6").empty());
+ EXPECT_TRUE(string::from_hex("66:612").empty());
+ EXPECT_TRUE(string::from_hex("66:WW").empty());
}
TEST(StringTests, uppercase_lowercaseInput_uppercaseOutput)
diff --git a/src/test/unittests/ipc/IpcLogOutputterTests.cpp b/src/test/unittests/ipc/IpcLogOutputterTests.cpp
index bbfed9c..6db9ac9 100644
--- a/src/test/unittests/ipc/IpcLogOutputterTests.cpp
+++ b/src/test/unittests/ipc/IpcLogOutputterTests.cpp
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2015-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#define TEST_ENV
+#define BARRIER_TEST_ENV
#include "test/mock/ipc/MockIpcServer.h"
@@ -50,7 +50,7 @@ TEST(IpcLogOutputterTests, write_threadingEnabled_bufferIsSent)
{
MockIpcServer mockServer;
mockServer.delegateToFake();
-
+
ON_CALL(mockServer, hasClients(_)).WillByDefault(Return(true));
EXPECT_CALL(mockServer, hasClients(_)).Times(AtLeast(3));
@@ -67,7 +67,7 @@ TEST(IpcLogOutputterTests, write_threadingEnabled_bufferIsSent)
TEST(IpcLogOutputterTests, write_overBufferMaxSize_firstLineTruncated)
{
MockIpcServer mockServer;
-
+
ON_CALL(mockServer, hasClients(_)).WillByDefault(Return(true));
EXPECT_CALL(mockServer, hasClients(_)).Times(1);
EXPECT_CALL(mockServer, send(IpcLogLineMessageEq("mock 2\nmock 3\n"), _)).Times(1);
@@ -85,7 +85,7 @@ TEST(IpcLogOutputterTests, write_overBufferMaxSize_firstLineTruncated)
TEST(IpcLogOutputterTests, write_underBufferMaxSize_allLinesAreSent)
{
MockIpcServer mockServer;
-
+
ON_CALL(mockServer, hasClients(_)).WillByDefault(Return(true));
EXPECT_CALL(mockServer, hasClients(_)).Times(1);
@@ -107,7 +107,7 @@ TEST(IpcLogOutputterTests, write_underBufferMaxSize_allLinesAreSent)
TEST(IpcLogOutputterTests, write_overBufferRateLimit_lastLineTruncated)
{
MockIpcServer mockServer;
-
+
ON_CALL(mockServer, hasClients(_)).WillByDefault(Return(true));
EXPECT_CALL(mockServer, hasClients(_)).Times(2);
@@ -123,7 +123,7 @@ TEST(IpcLogOutputterTests, write_overBufferRateLimit_lastLineTruncated)
outputter.write(kNOTE, "mock 3");
outputter.sendBuffer();
-
+
// after waiting the time limit send another to make sure
// we can log after the time limit passes.
// HACK: sleep causes the unit test to fail intermittently,
@@ -140,7 +140,7 @@ TEST(IpcLogOutputterTests, write_overBufferRateLimit_lastLineTruncated)
TEST(IpcLogOutputterTests, write_underBufferRateLimit_allLinesAreSent)
{
MockIpcServer mockServer;
-
+
ON_CALL(mockServer, hasClients(_)).WillByDefault(Return(true));
EXPECT_CALL(mockServer, hasClients(_)).Times(2);
@@ -154,7 +154,7 @@ TEST(IpcLogOutputterTests, write_underBufferRateLimit_allLinesAreSent)
outputter.write(kNOTE, "mock 1");
outputter.write(kNOTE, "mock 2");
outputter.sendBuffer();
-
+
// after waiting the time limit send another to make sure
// we can log after the time limit passes.
outputter.write(kNOTE, "mock 3");
diff --git a/src/test/unittests/net/FingerprintDatabaseTests.cpp b/src/test/unittests/net/FingerprintDatabaseTests.cpp
new file mode 100644
index 0000000..61bed0e
--- /dev/null
+++ b/src/test/unittests/net/FingerprintDatabaseTests.cpp
@@ -0,0 +1,95 @@
+/*
+ barrier -- mouse and keyboard sharing utility
+ Copyright (C) Barrier contributors
+
+ This package is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ found in the file LICENSE that should have accompanied this file.
+
+ This package is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "net/FingerprintDatabase.h"
+#include "test/global/gtest.h"
+
+namespace barrier {
+
+TEST(FingerprintDatabase, parse_db_line)
+{
+ ASSERT_FALSE(FingerprintDatabase::parse_db_line("").valid());
+ ASSERT_FALSE(FingerprintDatabase::parse_db_line("abcd").valid());
+ ASSERT_FALSE(FingerprintDatabase::parse_db_line("v1:algo:something").valid());
+ ASSERT_FALSE(FingerprintDatabase::parse_db_line("v2:algo:something").valid());
+ ASSERT_FALSE(FingerprintDatabase::parse_db_line("v2:algo:01020304abc").valid());
+ ASSERT_FALSE(FingerprintDatabase::parse_db_line("v2:algo:01020304ZZ").valid());
+ ASSERT_EQ(FingerprintDatabase::parse_db_line("v2:algo:01020304ab"),
+ (FingerprintData{"algo", {1, 2, 3, 4, 0xab}}));
+}
+
+TEST(FingerprintDatabase, read)
+{
+ std::istringstream stream;
+ stream.str(R"(
+v2:algo1:01020304ab
+v2:algo2:03040506ab
+AB:CD:EF:00:01:02:03:04:05:06:07:08:09:10:11:12:13:14:15:16
+)");
+ FingerprintDatabase db;
+ db.read_stream(stream);
+
+ std::vector<FingerprintData> expected = {
+ { "algo1", { 1, 2, 3, 4, 0xab } },
+ { "algo2", { 3, 4, 5, 6, 0xab } },
+ { "sha1", { 0xab, 0xcd, 0xef, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16 } },
+ };
+ ASSERT_EQ(db.fingerprints(), expected);
+}
+
+TEST(FingerprintDatabase, write)
+{
+ std::ostringstream stream;
+
+ FingerprintDatabase db;
+ db.add_trusted({ "algo1", { 1, 2, 3, 4, 0xab } });
+ db.add_trusted({ "algo2", { 3, 4, 5, 6, 0xab } });
+ db.write_stream(stream);
+
+ ASSERT_EQ(stream.str(), R"(v2:algo1:01020304ab
+v2:algo2:03040506ab
+)");
+}
+
+TEST(FingerprintDatabase, clear)
+{
+ FingerprintDatabase db;
+ db.add_trusted({ "algo1", { 1, 2, 3, 4, 0xab } });
+ db.clear();
+ ASSERT_TRUE(db.fingerprints().empty());
+}
+
+TEST(FingerprintDatabase, add_trusted_no_duplicates)
+{
+ FingerprintDatabase db;
+ db.add_trusted({ "algo1", { 1, 2, 3, 4, 0xab } });
+ db.add_trusted({ "algo2", { 3, 4, 5, 6, 0xab } });
+ db.add_trusted({ "algo1", { 1, 2, 3, 4, 0xab } });
+ ASSERT_EQ(db.fingerprints().size(), 2);
+}
+
+TEST(FingerprintDatabase, is_trusted)
+{
+ FingerprintDatabase db;
+ db.add_trusted({ "algo1", { 1, 2, 3, 4, 0xab } });
+ ASSERT_TRUE(db.is_trusted({ "algo1", { 1, 2, 3, 4, 0xab } }));
+ ASSERT_FALSE(db.is_trusted({ "algo2", { 1, 2, 3, 4, 0xab } }));
+ ASSERT_FALSE(db.is_trusted({ "algo1", { 1, 2, 3, 4, 0xac } }));
+}
+
+} // namespace barrier
diff --git a/src/test/unittests/net/SecureUtilsTests.cpp b/src/test/unittests/net/SecureUtilsTests.cpp
new file mode 100644
index 0000000..0cce693
--- /dev/null
+++ b/src/test/unittests/net/SecureUtilsTests.cpp
@@ -0,0 +1,73 @@
+/*
+ barrier -- mouse and keyboard sharing utility
+ Copyright (C) 2021 Barrier contributors
+
+ This package is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ found in the file LICENSE that should have accompanied this file.
+
+ This package is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "net/SecureUtils.h"
+
+#include "test/global/gtest.h"
+#include "test/global/TestUtils.h"
+
+namespace barrier {
+
+TEST(SecureUtilsTest, FormatSslFingerprintHexWithSeparators)
+{
+ auto fingerprint = generate_pseudo_random_bytes(0, 32);
+ ASSERT_EQ(format_ssl_fingerprint(fingerprint, true),
+ "28:FD:0A:98:8A:0E:A1:6C:D7:E8:6C:A7:EE:58:41:71:"
+ "CA:B2:8E:49:25:94:90:25:26:05:8D:AF:63:ED:2E:30");
+}
+
+TEST(SecureUtilsTest, CreateFingerprintRandomArt)
+{
+ ASSERT_EQ(create_fingerprint_randomart(generate_pseudo_random_bytes(0, 32)),
+ "+-----------------+\n"
+ "|*X+. . |\n"
+ "|*oo + |\n"
+ "| + = |\n"
+ "| B . . |\n"
+ "|.+... o S |\n"
+ "|E+ ++. . |\n"
+ "|B*++.. . |\n"
+ "|+o*o o . |\n"
+ "|+o*Bo . |\n"
+ "+-----------------+");
+ ASSERT_EQ(create_fingerprint_randomart(generate_pseudo_random_bytes(1, 32)),
+ "+-----------------+\n"
+ "| .oo+ . .B=. |\n"
+ "| .o.+ . o o.= |\n"
+ "|o..+.. o . E * |\n"
+ "|oo..+ . * * |\n"
+ "|B o.....S. o . |\n"
+ "|+=o..... |\n"
+ "| + + . |\n"
+ "|o. .. |\n"
+ "|..o.. |\n"
+ "+-----------------+");
+ ASSERT_EQ(create_fingerprint_randomart(generate_pseudo_random_bytes(2, 32)),
+ "+-----------------+\n"
+ "| ... .o.o.|\n"
+ "| o .=.E|\n"
+ "| . + o ...+.|\n"
+ "| * o = o ... |\n"
+ "| * + S & . |\n"
+ "| = + % @ |\n"
+ "| . . = X o |\n"
+ "| . . O . |\n"
+ "| . + |\n"
+ "+-----------------+");
+}
+
+} // namespace barrier
diff --git a/src/test/unittests/platform/OSXKeyStateTests.cpp b/src/test/unittests/platform/OSXKeyStateTests.cpp
index dd9e80f..0e4ec83 100644
--- a/src/test/unittests/platform/OSXKeyStateTests.cpp
+++ b/src/test/unittests/platform/OSXKeyStateTests.cpp
@@ -30,27 +30,27 @@ TEST(OSXKeyStateTests, mapModifiersFromOSX_OSXMask_returnBarrierMask)
OSXKeyState keyState(&eventQueue, keyMap);
KeyModifierMask outMask = 0;
-
+
UInt32 shiftMask = 0 | kCGEventFlagMaskShift;
outMask = keyState.mapModifiersFromOSX(shiftMask);
EXPECT_EQ(KeyModifierShift, outMask);
-
+
UInt32 ctrlMask = 0 | kCGEventFlagMaskControl;
outMask = keyState.mapModifiersFromOSX(ctrlMask);
EXPECT_EQ(KeyModifierControl, outMask);
-
+
UInt32 altMask = 0 | kCGEventFlagMaskAlternate;
outMask = keyState.mapModifiersFromOSX(altMask);
EXPECT_EQ(KeyModifierAlt, outMask);
-
+
UInt32 cmdMask = 0 | kCGEventFlagMaskCommand;
outMask = keyState.mapModifiersFromOSX(cmdMask);
EXPECT_EQ(KeyModifierSuper, outMask);
-
+
UInt32 capsMask = 0 | kCGEventFlagMaskAlphaShift;
outMask = keyState.mapModifiersFromOSX(capsMask);
EXPECT_EQ(KeyModifierCapsLock, outMask);
-
+
UInt32 numMask = 0 | kCGEventFlagMaskNumericPad;
outMask = keyState.mapModifiersFromOSX(numMask);
EXPECT_EQ(KeyModifierNumLock, outMask);