aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/integtests
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2021-11-10 00:54:35 -0500
committerLibravatarUnit 193 <unit193@unit193.net>2021-11-10 00:54:35 -0500
commit58fb7a0cee13d84170aac52f3f89d91888e1afe3 (patch)
tree1d6312ba15f9ece5a8031e5280dfb8b38be8dfa3 /src/test/integtests
parent28db84b46139c9bb2bbcac8c6cc56e71d1e35629 (diff)
parentbeb08eb751fa8e1f72042f263316ab5e5ddb596d (diff)
Update upstream source from tag 'upstream/2.4.0+dfsg'
Update to upstream version '2.4.0+dfsg' with Debian dir 4b6668cc08c7b0e56b1e1f7b4e89ecdb316182a0
Diffstat (limited to 'src/test/integtests')
-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
12 files changed, 135 insertions, 129 deletions
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);