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:
Nick Bolton
2013-07-16 19:02:30 +00:00
parent 6f97f1d186
commit c368013f13
56 changed files with 830 additions and 165 deletions

View File

@@ -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

View File

@@ -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));
};

View 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&));
};

View 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*));
};

View 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));
};

View 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());
};