Merge pull request #719 from p12tic/tests

Fix building of tests
This commit is contained in:
Dom Rodriguez 2020-05-30 21:14:08 +01:00 committed by GitHub
commit 5d0f6e6f73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 47 additions and 101 deletions

View File

@ -19,6 +19,7 @@ include_directories (${CMAKE_CURRENT_BINARY_DIR}/lib)
add_subdirectory(lib)
add_subdirectory(cmd)
add_subdirectory(test)
if (BARRIER_BUILD_GUI)
add_subdirectory(gui)

View File

@ -173,6 +173,6 @@ private:
public:
SInt32 group() const { return m_group; }
void group(const SInt32& group) { m_group = group; }
KeyModifierMaskList modifierFromX() const { return m_modifierFromX; }
KeyModifierMaskList& modifierFromX() { return m_modifierFromX; }
#endif
};

View File

@ -19,7 +19,7 @@
#include "base/EventQueue.h"
class EventQueueTimer;
class EventQueueTimer {};
class TestEventQueue : public EventQueue {
public:

View File

@ -14,24 +14,37 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
file(GLOB_RECURSE headers "*.h")
file(GLOB_RECURSE sources "*.cpp")
# remove platform files (specific platform added later).
file(GLOB_RECURSE remove_platform "platform/*")
list(REMOVE_ITEM headers ${remove_platform})
list(REMOVE_ITEM sources ${remove_platform})
set(headers
)
set(sources
arch/ArchInternetTests.cpp
ipc/IpcTests.cpp
net/NetworkTests.cpp
Main.cpp
)
# platform
if (WIN32)
file(GLOB platform_sources "platform/MSWindows*.cpp")
file(GLOB platform_headers "platform/MSWindows*.h")
set(platform_sources
platform/MSWindowsClipboardTests.cpp
platform/MSWindowsKeyStateTests.cpp
)
set(platform_headers)
elseif (APPLE)
file(GLOB platform_sources "platform/OSX*.cpp")
file(GLOB platform_headers "platform/OSX*.h")
set(platform_sources
platform/OSXClipboardTests.cpp
platform/OSXKeyStateTests.cpp
platform/OSXScreenTests.cpp
)
set(platform_headers)
elseif (UNIX)
file(GLOB platform_sources "platform/XWindows*.cpp")
file(GLOB platform_headers "platform/XWindows*.h")
set(platform_sources
platform/XWindowsClipboardTests.cpp
platform/XWindowsKeyStateTests.cpp
platform/XWindowsScreenSaverTests.cpp
platform/XWindowsScreenTests.cpp
)
set(platform_headers)
endif()
list(APPEND sources ${platform_sources})
@ -55,7 +68,6 @@ endif()
include_directories(
../../
../../lib/
../../../ext/gtest/include
../../../ext/gmock/include
)
@ -68,4 +80,4 @@ endif()
add_executable(integtests ${sources})
target_link_libraries(integtests
arch base client common io ipc mt net platform server barrier gtest gmock ${libs} ${OPENSSL_LIBS})
arch base client common io ipc mt net platform server synlib gtest gmock ${libs} ${OPENSSL_LIBS})

View File

@ -22,16 +22,16 @@
#define TEST_URL "https://symless.com/tests/?testString"
//#define TEST_URL "http://localhost/barrier/tests/?testString"
TEST(ArchInternetTests, get)
TEST(ArchInternetTests, DISABLED_get)
{
ARCH_INTERNET internet;
String result = internet.get(TEST_URL);
std::string result = internet.get(TEST_URL);
ASSERT_EQ("Hello world!", result);
}
TEST(ArchInternetTests, urlEncode)
{
ARCH_INTERNET internet;
String result = internet.urlEncode("hello=+&world");
std::string result = internet.urlEncode("hello=+&world");
ASSERT_EQ("hello%3D%2B%26world", result);
}

View File

@ -76,8 +76,7 @@ TEST_F(XWindowsKeyStateTests, setActiveGroup_pollAndSet_groupIsZero)
{
MockKeyMap keyMap;
MockEventQueue eventQueue;
XWindowsKeyState keyState(
m_display, true, &eventQueue, keyMap);
XWindowsKeyState keyState(new XWindowsImpl(), m_display, true, &eventQueue, keyMap);
keyState.setActiveGroup(XWindowsKeyState::kGroupPollAndSet);
@ -88,8 +87,7 @@ TEST_F(XWindowsKeyStateTests, setActiveGroup_poll_groupIsNotSet)
{
MockKeyMap keyMap;
MockEventQueue eventQueue;
XWindowsKeyState keyState(
m_display, true, &eventQueue, keyMap);
XWindowsKeyState keyState(new XWindowsImpl(), m_display, true, &eventQueue, keyMap);
keyState.setActiveGroup(XWindowsKeyState::kGroupPoll);
@ -100,8 +98,7 @@ TEST_F(XWindowsKeyStateTests, setActiveGroup_customGroup_groupWasSet)
{
MockKeyMap keyMap;
MockEventQueue eventQueue;
XWindowsKeyState keyState(
m_display, true, &eventQueue, keyMap);
XWindowsKeyState keyState(new XWindowsImpl(), m_display, true, &eventQueue, keyMap);
keyState.setActiveGroup(1);
@ -112,8 +109,7 @@ TEST_F(XWindowsKeyStateTests, mapModifiersFromX_zeroState_zeroMask)
{
MockKeyMap keyMap;
MockEventQueue eventQueue;
XWindowsKeyState keyState(
m_display, true, &eventQueue, keyMap);
XWindowsKeyState keyState(new XWindowsImpl(), m_display, true, &eventQueue, keyMap);
int mask = keyState.mapModifiersFromX(0);
@ -124,8 +120,7 @@ TEST_F(XWindowsKeyStateTests, mapModifiersToX_zeroMask_resultIsTrue)
{
MockKeyMap keyMap;
MockEventQueue eventQueue;
XWindowsKeyState keyState(
m_display, true, &eventQueue, keyMap);
XWindowsKeyState keyState(new XWindowsImpl(), m_display, true, &eventQueue, keyMap);
unsigned int modifiers = 0;
bool result = keyState.mapModifiersToX(0, modifiers);
@ -137,8 +132,7 @@ TEST_F(XWindowsKeyStateTests, fakeCtrlAltDel_default_returnsFalse)
{
MockKeyMap keyMap;
MockEventQueue eventQueue;
XWindowsKeyState keyState(
m_display, true, &eventQueue, keyMap);
XWindowsKeyState keyState(new XWindowsImpl(), m_display, true, &eventQueue, keyMap);
bool result = keyState.fakeCtrlAltDel();
@ -149,21 +143,18 @@ TEST_F(XWindowsKeyStateTests, pollActiveModifiers_defaultState_returnsZero)
{
MockKeyMap keyMap;
MockEventQueue eventQueue;
XWindowsKeyState keyState(
m_display, true, &eventQueue, keyMap);
XWindowsKeyState keyState(new XWindowsImpl(), m_display, true, &eventQueue, keyMap);
KeyModifierMask actual = keyState.pollActiveModifiers();
ASSERT_EQ(0, actual);
}
#if 0 // TODO: fix, causes sigsegv
TEST_F(XWindowsKeyStateTests, pollActiveModifiers_shiftKeyDownThenUp_masksAreCorrect)
{
MockKeyMap keyMap;
MockEventQueue eventQueue;
XWindowsKeyState keyState(
m_display, true, &eventQueue, keyMap);
XWindowsKeyState keyState(new XWindowsImpl(), m_display, true, &eventQueue, keyMap);
// set mock modifier mapping
std::fill(keyState.modifierFromX().begin(), keyState.modifierFromX().end(), 0);
@ -189,14 +180,12 @@ TEST_F(XWindowsKeyStateTests, pollActiveModifiers_shiftKeyDownThenUp_masksAreCor
EXPECT_TRUE((modUp & KeyModifierShift) == 0)
<< "shift key still in mask - make sure no keys are being held down";
}
#endif
TEST_F(XWindowsKeyStateTests, pollActiveGroup_defaultState_returnsZero)
{
MockKeyMap keyMap;
MockEventQueue eventQueue;
XWindowsKeyState keyState(
m_display, true, &eventQueue, keyMap);
XWindowsKeyState keyState(new XWindowsImpl(), m_display, true, &eventQueue, keyMap);
SInt32 actual = keyState.pollActiveGroup();
@ -207,8 +196,7 @@ TEST_F(XWindowsKeyStateTests, pollActiveGroup_positiveGroup_returnsGroup)
{
MockKeyMap keyMap;
MockEventQueue eventQueue;
XWindowsKeyState keyState(
m_display, true, &eventQueue, keyMap);
XWindowsKeyState keyState(new XWindowsImpl(), m_display, true, &eventQueue, keyMap);
keyState.group(3);
@ -222,8 +210,7 @@ TEST_F(XWindowsKeyStateTests, pollActiveGroup_xkb_areEqual)
#if HAVE_XKB_EXTENSION
MockKeyMap keyMap;
MockEventQueue eventQueue;
XWindowsKeyState keyState(
m_display, true, &eventQueue, keyMap);
XWindowsKeyState keyState(new XWindowsImpl(), m_display, true, &eventQueue, keyMap);
// reset the group
keyState.group(-1);

View File

@ -29,12 +29,11 @@ TEST(CXWindowsScreenTests, fakeMouseMove_nonPrimary_getCursorPosValuesCorrect)
EXPECT_CALL(eventQueue, adoptHandler(_, _, _)).Times(2);
EXPECT_CALL(eventQueue, adoptBuffer(_)).Times(2);
EXPECT_CALL(eventQueue, removeHandler(_, _)).Times(2);
XWindowsScreen screen(
":0.0", false, false, 0, &eventQueue);
XWindowsScreen screen(new XWindowsImpl(), ":0.0", false, false, 0, &eventQueue);
screen.fakeMouseMove(10, 20);
int x, y;
SInt32 x, y;
screen.getCursorPos(x, y);
ASSERT_EQ(10, x);
ASSERT_EQ(20, y);

View File

@ -50,7 +50,6 @@ list(APPEND headers ${platform_sources})
include_directories(
../../
../../lib/
../../../ext/gtest/include
../../../ext/gmock/include
../../../ext
@ -68,4 +67,4 @@ endif()
add_executable(unittests ${sources})
target_link_libraries(unittests
arch base client server common io net platform server barrier mt ipc gtest gmock ${libs} ${OPENSSL_LIBS})
arch base client server common io net platform server synlib mt ipc gtest gmock ${libs} ${OPENSSL_LIBS})

View File

@ -22,7 +22,6 @@
TEST(ClipboardChunkTests, start_formatStartChunk)
{
<<<<<<< HEAD
ClipboardID id = 0;
UInt32 sequence = 0;
String mockDataSize("10");
@ -34,28 +33,12 @@ TEST(ClipboardChunkTests, start_formatStartChunk)
EXPECT_EQ('1', chunk->m_chunk[6]);
EXPECT_EQ('0', chunk->m_chunk[7]);
EXPECT_EQ('\0', chunk->m_chunk[8]);
=======
ClipboardID id = 0;
UInt32 sequence = 0;
String mockDataSize("10");
ClipboardChunk* chunk = ClipboardChunk::start(id, sequence, mockDataSize);
UInt32 temp_m_chunk;
memcpy(&temp_m_chunk, &(chunk->m_chunk[1]), 4);
EXPECT_EQ(id, chunk->m_chunk[0]);
EXPECT_EQ(sequence, temp_m_chunk);
EXPECT_EQ(kDataStart, chunk->m_chunk[5]);
EXPECT_EQ('1', chunk->m_chunk[6]);
EXPECT_EQ('0', chunk->m_chunk[7]);
EXPECT_EQ('\0', chunk->m_chunk[8]);
>>>>>>> master
delete chunk;
}
TEST(ClipboardChunkTests, data_formatDataChunk)
{
<<<<<<< HEAD
ClipboardID id = 0;
UInt32 sequence = 1;
String mockData("mock data");
@ -74,35 +57,12 @@ TEST(ClipboardChunkTests, data_formatDataChunk)
EXPECT_EQ('t', chunk->m_chunk[13]);
EXPECT_EQ('a', chunk->m_chunk[14]);
EXPECT_EQ('\0', chunk->m_chunk[15]);
=======
ClipboardID id = 0;
UInt32 sequence = 1;
String mockData("mock data");
ClipboardChunk* chunk = ClipboardChunk::data(id, sequence, mockData);
UInt32 temp_m_chunk;
memcpy(&temp_m_chunk, &(chunk->m_chunk[1]), 4);
EXPECT_EQ(id, chunk->m_chunk[0]);
EXPECT_EQ(sequence, temp_m_chunk);
EXPECT_EQ(kDataChunk, chunk->m_chunk[5]);
EXPECT_EQ('m', chunk->m_chunk[6]);
EXPECT_EQ('o', chunk->m_chunk[7]);
EXPECT_EQ('c', chunk->m_chunk[8]);
EXPECT_EQ('k', chunk->m_chunk[9]);
EXPECT_EQ(' ', chunk->m_chunk[10]);
EXPECT_EQ('d', chunk->m_chunk[11]);
EXPECT_EQ('a', chunk->m_chunk[12]);
EXPECT_EQ('t', chunk->m_chunk[13]);
EXPECT_EQ('a', chunk->m_chunk[14]);
EXPECT_EQ('\0', chunk->m_chunk[15]);
>>>>>>> master
delete chunk;
}
TEST(ClipboardChunkTests, end_formatDataChunk)
{
<<<<<<< HEAD
ClipboardID id = 1;
UInt32 sequence = 1;
ClipboardChunk* chunk = ClipboardChunk::end(id, sequence);
@ -111,18 +71,6 @@ TEST(ClipboardChunkTests, end_formatDataChunk)
EXPECT_EQ(sequence, (UInt32)chunk->m_chunk[1]);
EXPECT_EQ(kDataEnd, chunk->m_chunk[5]);
EXPECT_EQ('\0', chunk->m_chunk[6]);
=======
ClipboardID id = 1;
UInt32 sequence = 1;
ClipboardChunk* chunk = ClipboardChunk::end(id, sequence);
UInt32 temp_m_chunk;
memcpy(&temp_m_chunk, &(chunk->m_chunk[1]), 4);
EXPECT_EQ(id, chunk->m_chunk[0]);
EXPECT_EQ(sequence, temp_m_chunk);
EXPECT_EQ(kDataEnd, chunk->m_chunk[5]);
EXPECT_EQ('\0', chunk->m_chunk[6]);
>>>>>>> master
delete chunk;
}