summaryrefslogtreecommitdiffstats
path: root/src/test/mock/barrier
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/mock/barrier')
-rw-r--r--src/test/mock/barrier/MockApp.h44
-rw-r--r--src/test/mock/barrier/MockArgParser.h33
-rw-r--r--src/test/mock/barrier/MockEventQueue.h67
-rw-r--r--src/test/mock/barrier/MockKeyMap.h36
-rw-r--r--src/test/mock/barrier/MockKeyState.h57
-rw-r--r--src/test/mock/barrier/MockScreen.h36
6 files changed, 273 insertions, 0 deletions
diff --git a/src/test/mock/barrier/MockApp.h b/src/test/mock/barrier/MockApp.h
new file mode 100644
index 0000000..91745d3
--- /dev/null
+++ b/src/test/mock/barrier/MockApp.h
@@ -0,0 +1,44 @@
+/*
+ * 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
+ * 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/>.
+ */
+
+#pragma once
+
+#define TEST_ENV
+
+#include "barrier/App.h"
+
+#include "test/global/gmock.h"
+
+class MockApp : public App
+{
+public:
+ MockApp() : App(NULL, NULL, NULL) { }
+
+ MOCK_METHOD0(help, void());
+ MOCK_METHOD0(loadConfig, void());
+ MOCK_METHOD1(loadConfig, bool(const String&));
+ MOCK_CONST_METHOD0(daemonInfo, const char*());
+ MOCK_CONST_METHOD0(daemonName, const char*());
+ MOCK_METHOD2(parseArgs, void(int, const char* const*));
+ MOCK_METHOD0(version, void());
+ MOCK_METHOD2(standardStartup, int(int, char**));
+ MOCK_METHOD4(runInner, int(int, char**, ILogOutputter*, StartupFunc));
+ MOCK_METHOD0(startNode, void());
+ MOCK_METHOD0(mainLoop, int());
+ MOCK_METHOD2(foregroundStartup, int(int, char**));
+ MOCK_METHOD0(createScreen, barrier::Screen*());
+};
diff --git a/src/test/mock/barrier/MockArgParser.h b/src/test/mock/barrier/MockArgParser.h
new file mode 100644
index 0000000..b1dc07c
--- /dev/null
+++ b/src/test/mock/barrier/MockArgParser.h
@@ -0,0 +1,33 @@
+/*
+ * 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
+ * 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/>.
+ */
+
+#pragma once
+
+#define TEST_ENV
+
+#include "barrier/ArgParser.h"
+
+#include "test/global/gmock.h"
+
+class MockArgParser : public ArgParser
+{
+public:
+ MockArgParser() : ArgParser(NULL) { }
+
+ MOCK_METHOD3(parseGenericArgs, bool(int, const char* const*, int&));
+ MOCK_METHOD0(checkUnexpectedArgs, bool());
+};
diff --git a/src/test/mock/barrier/MockEventQueue.h b/src/test/mock/barrier/MockEventQueue.h
new file mode 100644
index 0000000..f273736
--- /dev/null
+++ b/src/test/mock/barrier/MockEventQueue.h
@@ -0,0 +1,67 @@
+/*
+ * 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/>.
+ */
+
+#pragma once
+
+#include "base/IEventQueue.h"
+
+#include "test/global/gmock.h"
+
+class MockEventQueue : public IEventQueue
+{
+public:
+ MOCK_METHOD0(loop, void());
+ MOCK_METHOD2(newOneShotTimer, EventQueueTimer*(double, void*));
+ MOCK_METHOD2(newTimer, EventQueueTimer*(double, void*));
+ MOCK_METHOD2(getEvent, bool(Event&, double));
+ MOCK_METHOD1(adoptBuffer, void(IEventQueueBuffer*));
+ MOCK_METHOD2(registerTypeOnce, Event::Type(Event::Type&, const char*));
+ MOCK_METHOD1(removeHandlers, void(void*));
+ MOCK_METHOD1(registerType, Event::Type(const char*));
+ MOCK_CONST_METHOD0(isEmpty, bool());
+ MOCK_METHOD3(adoptHandler, void(Event::Type, void*, IEventJob*));
+ MOCK_METHOD1(getTypeName, const char*(Event::Type));
+ MOCK_METHOD1(addEvent, void(const Event&));
+ MOCK_METHOD2(removeHandler, void(Event::Type, void*));
+ MOCK_METHOD1(dispatchEvent, bool(const Event&));
+ MOCK_CONST_METHOD2(getHandler, IEventJob*(Event::Type, void*));
+ MOCK_METHOD1(deleteTimer, void(EventQueueTimer*));
+ MOCK_CONST_METHOD1(getRegisteredType, Event::Type(const String&));
+ MOCK_METHOD0(getSystemTarget, void*());
+ MOCK_METHOD0(forClient, ClientEvents&());
+ MOCK_METHOD0(forIStream, IStreamEvents&());
+ MOCK_METHOD0(forIpcClient, IpcClientEvents&());
+ MOCK_METHOD0(forIpcClientProxy, IpcClientProxyEvents&());
+ MOCK_METHOD0(forIpcServer, IpcServerEvents&());
+ MOCK_METHOD0(forIpcServerProxy, IpcServerProxyEvents&());
+ MOCK_METHOD0(forIDataSocket, IDataSocketEvents&());
+ MOCK_METHOD0(forIListenSocket, IListenSocketEvents&());
+ MOCK_METHOD0(forISocket, ISocketEvents&());
+ MOCK_METHOD0(forOSXScreen, OSXScreenEvents&());
+ MOCK_METHOD0(forClientListener, ClientListenerEvents&());
+ MOCK_METHOD0(forClientProxy, ClientProxyEvents&());
+ MOCK_METHOD0(forClientProxyUnknown, ClientProxyUnknownEvents&());
+ MOCK_METHOD0(forServer, ServerEvents&());
+ MOCK_METHOD0(forServerApp, ServerAppEvents&());
+ MOCK_METHOD0(forIKeyState, IKeyStateEvents&());
+ MOCK_METHOD0(forIPrimaryScreen, IPrimaryScreenEvents&());
+ MOCK_METHOD0(forIScreen, IScreenEvents&());
+ MOCK_METHOD0(forClipboard, ClipboardEvents&());
+ MOCK_METHOD0(forFile, FileEvents&());
+ MOCK_CONST_METHOD0(waitForReady, void());
+};
diff --git a/src/test/mock/barrier/MockKeyMap.h b/src/test/mock/barrier/MockKeyMap.h
new file mode 100644
index 0000000..ef711a5
--- /dev/null
+++ b/src/test/mock/barrier/MockKeyMap.h
@@ -0,0 +1,36 @@
+/*
+ * 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/>.
+ */
+
+#pragma once
+
+#include "barrier/KeyMap.h"
+
+#include "test/global/gmock.h"
+
+class MockKeyMap : public barrier::KeyMap
+{
+public:
+ MOCK_METHOD1(swap, void(KeyMap&));
+ MOCK_METHOD0(finish, void());
+ MOCK_METHOD2(foreachKey, void(ForeachKeyCallback, void*));
+ MOCK_METHOD1(addHalfDuplexModifier, void(KeyID));
+ MOCK_CONST_METHOD2(isHalfDuplex, bool(KeyID, KeyButton));
+ MOCK_CONST_METHOD7(mapKey, const KeyMap::KeyItem*(
+ Keystrokes&, KeyID, SInt32, ModifierToKeys&, KeyModifierMask&,
+ KeyModifierMask, bool));
+};
diff --git a/src/test/mock/barrier/MockKeyState.h b/src/test/mock/barrier/MockKeyState.h
new file mode 100644
index 0000000..308e90a
--- /dev/null
+++ b/src/test/mock/barrier/MockKeyState.h
@@ -0,0 +1,57 @@
+/*
+ * 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/>.
+ */
+
+#pragma once
+
+#include "barrier/KeyState.h"
+
+#include "test/global/gmock.h"
+
+class MockKeyMap;
+class MockEventQueue;
+
+// NOTE: do not mock methods that are not pure virtual. this mock exists only
+// to provide an implementation of the KeyState abstract class.
+class MockKeyState : public KeyState
+{
+public:
+ MockKeyState(const MockEventQueue& eventQueue) :
+ KeyState((IEventQueue*)&eventQueue)
+ {
+ }
+
+ MockKeyState(const MockEventQueue& eventQueue, const MockKeyMap& keyMap) :
+ KeyState((IEventQueue*)&eventQueue, (barrier::KeyMap&)keyMap)
+ {
+ }
+
+ MOCK_CONST_METHOD0(pollActiveGroup, SInt32());
+ MOCK_CONST_METHOD0(pollActiveModifiers, KeyModifierMask());
+ MOCK_METHOD0(fakeCtrlAltDel, bool());
+ MOCK_METHOD1(getKeyMap, void(barrier::KeyMap&));
+ MOCK_METHOD1(fakeKey, void(const Keystroke&));
+ MOCK_METHOD1(fakeMediaKey, bool(KeyID));
+ MOCK_CONST_METHOD1(pollPressedKeys, void(KeyButtonSet&));
+};
+
+typedef ::testing::NiceMock<MockKeyState> KeyStateImpl;
+
+typedef UInt32 KeyID;
+
+typedef void (*ForeachKeyCallback)(
+ KeyID, SInt32 group, barrier::KeyMap::KeyItem&, void* userData);
diff --git a/src/test/mock/barrier/MockScreen.h b/src/test/mock/barrier/MockScreen.h
new file mode 100644
index 0000000..78c195a
--- /dev/null
+++ b/src/test/mock/barrier/MockScreen.h
@@ -0,0 +1,36 @@
+/*
+ * 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
+ * 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/>.
+ */
+
+#pragma once
+
+#define TEST_ENV
+
+#include "barrier/Screen.h"
+
+#include "test/global/gmock.h"
+
+class MockScreen : public barrier::Screen
+{
+public:
+ MockScreen() : barrier::Screen() { }
+ MOCK_METHOD0(disable, void());
+ MOCK_CONST_METHOD4(getShape, void(SInt32&, SInt32&, SInt32&, SInt32&));
+ MOCK_CONST_METHOD2(getCursorPos, void(SInt32&, SInt32&));
+ MOCK_METHOD0(resetOptions, void());
+ MOCK_METHOD1(setOptions, void(const OptionsList&));
+ MOCK_METHOD0(enable, void());
+};