mirror of
https://github.com/debauchee/barrier.git
synced 2026-07-05 11:28:22 +08:00
Patch by Jerry for issue 46:
- Unit test for sending file data from server to client. - Removed singleton pattern from CSocketMultiplexer for easier unit testing. - Incremented protocol version from 1.4 to 1.5 (new file chunk message). - Storing pointer to CConfig instead of copying in CServer (so we can mock it). - Created a common event queue for testing (timeout, quit event, etc). - Fixed code style.
This commit is contained in:
@@ -22,6 +22,10 @@ set(h
|
||||
io/CMockStream.h
|
||||
server/CMockServer.h
|
||||
io/CMockCryptoStream.h
|
||||
synergy/CMockScreen.h
|
||||
server/CMockConfig.h
|
||||
server/CMockPrimaryClient.h
|
||||
server/CMockInputFilter.h
|
||||
)
|
||||
|
||||
set(src
|
||||
|
||||
@@ -26,7 +26,6 @@ class CMockCryptoStream : public CCryptoStream
|
||||
public:
|
||||
CMockCryptoStream(IEventQueue* eventQueue, IStream* stream) :
|
||||
CCryptoStream(eventQueue, stream, CCryptoOptions("gcm", "stub"), false) { }
|
||||
|
||||
MOCK_METHOD2(read, UInt32(void*, UInt32));
|
||||
MOCK_METHOD2(write, void(const void*, UInt32));
|
||||
};
|
||||
|
||||
31
src/test/unittests/server/CMockConfig.h
Normal file
31
src/test/unittests/server/CMockConfig.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2013 Bolton Software 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 COPYING 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 <gmock/gmock.h>
|
||||
|
||||
#define TEST_ENV
|
||||
#include "CConfig.h"
|
||||
|
||||
class CMockConfig : public CConfig
|
||||
{
|
||||
public:
|
||||
CMockConfig() : CConfig() { }
|
||||
MOCK_METHOD0(getInputFilter, CInputFilter*());
|
||||
MOCK_CONST_METHOD1(isScreen, bool(const CString&));
|
||||
};
|
||||
29
src/test/unittests/server/CMockInputFilter.h
Normal file
29
src/test/unittests/server/CMockInputFilter.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2013 Bolton Software 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 COPYING 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 <gmock/gmock.h>
|
||||
|
||||
#define TEST_ENV
|
||||
#include "CInputFilter.h"
|
||||
|
||||
class CMockInputFilter : public CInputFilter
|
||||
{
|
||||
public:
|
||||
MOCK_METHOD1(setPrimaryClient, void(CPrimaryClient*));
|
||||
};
|
||||
40
src/test/unittests/server/CMockPrimaryClient.h
Normal file
40
src/test/unittests/server/CMockPrimaryClient.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2013 Bolton Software 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 COPYING 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 <gmock/gmock.h>
|
||||
|
||||
#define TEST_ENV
|
||||
#include "CPrimaryClient.h"
|
||||
#include "CString.h"
|
||||
|
||||
class CMockPrimaryClient : public CPrimaryClient
|
||||
{
|
||||
public:
|
||||
MOCK_CONST_METHOD0(getEventTarget, void*());
|
||||
MOCK_CONST_METHOD2(getCursorPos, void(SInt32&, SInt32&));
|
||||
MOCK_CONST_METHOD2(setJumpCursorPos, void(SInt32, SInt32));
|
||||
MOCK_METHOD1(reconfigure, void(UInt32));
|
||||
MOCK_METHOD0(resetOptions, void());
|
||||
MOCK_METHOD1(setOptions, void(const COptionsList&));
|
||||
MOCK_METHOD0(enable, void());
|
||||
MOCK_METHOD0(disable, void());
|
||||
MOCK_METHOD2(registerHotKey, UInt32(KeyID, KeyModifierMask));
|
||||
MOCK_CONST_METHOD0(getToggleMask, KeyModifierMask());
|
||||
MOCK_METHOD1(unregisterHotKey, void(UInt32));
|
||||
};
|
||||
35
src/test/unittests/synergy/CMockScreen.h
Normal file
35
src/test/unittests/synergy/CMockScreen.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2013 Bolton Software 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 COPYING 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 <gmock/gmock.h>
|
||||
|
||||
#define TEST_ENV
|
||||
#include "CScreen.h"
|
||||
|
||||
class CMockScreen : public CScreen
|
||||
{
|
||||
public:
|
||||
CMockScreen() : CScreen() { }
|
||||
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 COptionsList&));
|
||||
MOCK_METHOD0(enable, void());
|
||||
};
|
||||
Reference in New Issue
Block a user