From ad8905ccbf7c33cb28008e6957d193825258c473 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Fri, 28 Feb 2014 13:56:07 +0000 Subject: [PATCH] fixed: silenced gtest warning on osx106 --- src/test/global/gmock.h | 32 +++++++++++++ src/test/global/gtest.h | 1 + src/test/integtests/CMakeLists.txt | 46 ++++++++++++++----- src/test/integtests/Main.cpp | 2 +- .../integtests/platform/OSXClipboardTests.cpp | 2 +- .../integtests/platform/OSXKeyStateTests.cpp | 8 ++-- .../integtests/platform/OSXScreenTests.cpp | 2 +- src/test/mock/client/MockClient.h | 2 +- src/test/mock/io/MockCryptoStream.h | 2 +- src/test/mock/io/MockStream.h | 2 +- src/test/mock/server/MockConfig.h | 2 +- src/test/mock/server/MockInputFilter.h | 2 +- src/test/mock/server/MockPrimaryClient.h | 2 +- src/test/mock/synergy/MockEventQueue.h | 2 +- src/test/mock/synergy/MockKeyMap.h | 2 +- src/test/mock/synergy/MockScreen.h | 2 +- src/test/unittests/CMakeLists.txt | 12 +++++ src/test/unittests/Main.cpp | 2 +- .../unittests/client/ServerProxyTests.cpp | 2 +- .../unittests/server/ClientProxyTests.cpp | 2 +- .../unittests/synergy/CryptoStreamTests.cpp | 2 +- src/test/unittests/synergy/KeyStateTests.cpp | 3 +- src/test/unittests/synergy/KeyStateTests.h | 2 +- 23 files changed, 102 insertions(+), 34 deletions(-) create mode 100644 src/test/global/gmock.h diff --git a/src/test/global/gmock.h b/src/test/global/gmock.h new file mode 100644 index 00000000..24e515c1 --- /dev/null +++ b/src/test/global/gmock.h @@ -0,0 +1,32 @@ +/* + * synergy -- mouse and keyboard sharing utility + * Copyright (C) 2014 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 . + */ + +#pragma once + +// HACK: gcc on osx106 doesn't give you an easy way to hide warnings +// from included headers, so use the system_header pragma. the downside +// is that everything in the header file following this also has warnings +// ignored, so we need to put it in a separate header file. +#if __APPLE__ +# pragma GCC system_header +#endif + +// gmock includes gtest which has a warning on osx106 (signed/unsigned +// int compare), so include our special header here first to silence +// the warning. +#include "test/global/gtest.h" +#include diff --git a/src/test/global/gtest.h b/src/test/global/gtest.h index 493c9025..0fa1681b 100644 --- a/src/test/global/gtest.h +++ b/src/test/global/gtest.h @@ -25,4 +25,5 @@ # pragma GCC system_header #endif +// gtest has a warning on osx106 (signed/unsigned int compare). #include diff --git a/src/test/integtests/CMakeLists.txt b/src/test/integtests/CMakeLists.txt index cf2ad6bc..ba40b6ad 100644 --- a/src/test/integtests/CMakeLists.txt +++ b/src/test/integtests/CMakeLists.txt @@ -14,16 +14,26 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -file(GLOB headers "*.h") -file(GLOB sources "*.cpp") +file(GLOB_RECURSE headers "*.h") +file(GLOB_RECURSE sources "*.cpp") + +# remove arch files (specific arch added later). +file(GLOB remove_arch "arch/*") +list(REMOVE_ITEM headers ${remove_arch}) +list(REMOVE_ITEM sources ${remove_arch}) + +# remove platform files (specific platform added later). +file(GLOB remove_platform "platform/*") +list(REMOVE_ITEM headers ${remove_platform}) +list(REMOVE_ITEM sources ${remove_platform}) # arch if (WIN32) - file(GLOB arch_sources "arch/CArchWindows*.cpp") - file(GLOB arch_headers "arch/CArchWindows*.h") + file(GLOB arch_sources "arch/ArchWindows*.cpp") + file(GLOB arch_headers "arch/ArchWindows*.h") elseif (UNIX) - file(GLOB arch_sources "arch/CArchUnix*.cpp") - file(GLOB arch_headers "arch/CArchUnix*.h") + file(GLOB arch_sources "arch/ArchUnix*.cpp") + file(GLOB arch_headers "arch/ArchUnix*.h") endif() list(APPEND sources ${arch_sources}) @@ -31,19 +41,31 @@ list(APPEND headers ${arch_headers}) # platform if (WIN32) - file(GLOB platform_sources "platform/CMSWindows*.cpp") - file(GLOB platform_headers "platform/CMSWindows*.h") + file(GLOB platform_sources "platform/MSWindows*.cpp") + file(GLOB platform_headers "platform/MSWindows*.h") elseif (APPLE) - file(GLOB platform_sources "platform/COSX*.cpp") - file(GLOB platform_headers "platform/COSX*.h") + file(GLOB platform_sources "platform/OSX*.cpp") + file(GLOB platform_headers "platform/OSX*.h") elseif (UNIX) - file(GLOB platform_sources "platform/CXWindows*.cpp") - file(GLOB platform_headers "platform/CXWindows*.h") + file(GLOB platform_sources "platform/XWindows*.cpp") + file(GLOB platform_headers "platform/XWindows*.h") endif() list(APPEND sources ${platform_sources}) list(APPEND headers ${platform_headers}) +file(GLOB_RECURSE global_headers "../../test/global/*.h") +file(GLOB_RECURSE global_sources "../../test/global/*.cpp") + +list(APPEND headers ${global_headers}) +list(APPEND sources ${global_sources}) + +file(GLOB_RECURSE mock_headers "../../test/mock/*.h") +file(GLOB_RECURSE mock_sources "../../test/mock/*.cpp") + +list(APPEND headers ${mock_headers}) +list(APPEND sources ${mock_sources}) + if (SYNERGY_ADD_HEADERS) list(APPEND sources ${headers}) endif() diff --git a/src/test/integtests/Main.cpp b/src/test/integtests/Main.cpp index 854423aa..afb17106 100644 --- a/src/test/integtests/Main.cpp +++ b/src/test/integtests/Main.cpp @@ -23,7 +23,7 @@ #include "arch/win32/ArchMiscWindows.h" #endif -#include +#include "test/global/gtest.h" #include #include diff --git a/src/test/integtests/platform/OSXClipboardTests.cpp b/src/test/integtests/platform/OSXClipboardTests.cpp index b65769ea..d2a4b4a7 100644 --- a/src/test/integtests/platform/OSXClipboardTests.cpp +++ b/src/test/integtests/platform/OSXClipboardTests.cpp @@ -18,7 +18,7 @@ #include "platform/OSXClipboard.h" -#include +#include "test/global/gtest.h" #include TEST(COSXClipboardTests, empty_openCalled_returnsTrue) diff --git a/src/test/integtests/platform/OSXKeyStateTests.cpp b/src/test/integtests/platform/OSXKeyStateTests.cpp index 29f60903..f1a02ad1 100644 --- a/src/test/integtests/platform/OSXKeyStateTests.cpp +++ b/src/test/integtests/platform/OSXKeyStateTests.cpp @@ -16,13 +16,13 @@ * along with this program. If not, see . */ +#include "test/mock/synergy/MockKeyMap.h" +#include "test/mock/synergy/MockEventQueue.h" #include "platform/OSXKeyState.h" -#include "synergy/CMockKeyMap.h" -#include "synergy/CMockEventQueue.h" #include "base/Log.h" -#include -#include +#include "test/global/gtest.h" +#include "test/global/gmock.h" #define SHIFT_ID_L kKeyShift_L #define SHIFT_ID_R kKeyShift_R diff --git a/src/test/integtests/platform/OSXScreenTests.cpp b/src/test/integtests/platform/OSXScreenTests.cpp index fc156097..648d355a 100644 --- a/src/test/integtests/platform/OSXScreenTests.cpp +++ b/src/test/integtests/platform/OSXScreenTests.cpp @@ -20,7 +20,7 @@ #include "arch/Arch.h" #include "base/EventQueue.h" -#include +#include "test/global/gtest.h" // disabling these tests - the return value of CGCursorIsVisible is unreliable. /* diff --git a/src/test/mock/client/MockClient.h b/src/test/mock/client/MockClient.h index 35de9856..d60b0883 100644 --- a/src/test/mock/client/MockClient.h +++ b/src/test/mock/client/MockClient.h @@ -22,7 +22,7 @@ #include "client/Client.h" -#include +#include "test/global/gmock.h" class IEventQueue; diff --git a/src/test/mock/io/MockCryptoStream.h b/src/test/mock/io/MockCryptoStream.h index d678cba8..3d36c626 100644 --- a/src/test/mock/io/MockCryptoStream.h +++ b/src/test/mock/io/MockCryptoStream.h @@ -20,7 +20,7 @@ #include "io/CryptoStream.h" #include "io/CryptoOptions.h" -#include +#include "test/global/gmock.h" class CMockCryptoStream : public CCryptoStream { diff --git a/src/test/mock/io/MockStream.h b/src/test/mock/io/MockStream.h index 441f672f..05155766 100644 --- a/src/test/mock/io/MockStream.h +++ b/src/test/mock/io/MockStream.h @@ -20,7 +20,7 @@ #include "io/IStream.h" -#include +#include "test/global/gmock.h" class IEventQueue; diff --git a/src/test/mock/server/MockConfig.h b/src/test/mock/server/MockConfig.h index b0987011..f3f3d9ae 100644 --- a/src/test/mock/server/MockConfig.h +++ b/src/test/mock/server/MockConfig.h @@ -21,7 +21,7 @@ #include "server/Config.h" -#include +#include "test/global/gmock.h" class CMockConfig : public CConfig { diff --git a/src/test/mock/server/MockInputFilter.h b/src/test/mock/server/MockInputFilter.h index 5736639d..a2b137bd 100644 --- a/src/test/mock/server/MockInputFilter.h +++ b/src/test/mock/server/MockInputFilter.h @@ -21,7 +21,7 @@ #include "server/InputFilter.h" -#include +#include "test/global/gmock.h" class CMockInputFilter : public CInputFilter { diff --git a/src/test/mock/server/MockPrimaryClient.h b/src/test/mock/server/MockPrimaryClient.h index 08d03f32..f8f04c86 100644 --- a/src/test/mock/server/MockPrimaryClient.h +++ b/src/test/mock/server/MockPrimaryClient.h @@ -22,7 +22,7 @@ #include "synergy/PrimaryClient.h" #include "base/String.h" -#include +#include "test/global/gmock.h" class CMockPrimaryClient : public CPrimaryClient { diff --git a/src/test/mock/synergy/MockEventQueue.h b/src/test/mock/synergy/MockEventQueue.h index bee65198..fc0077ae 100644 --- a/src/test/mock/synergy/MockEventQueue.h +++ b/src/test/mock/synergy/MockEventQueue.h @@ -20,7 +20,7 @@ #include "base/IEventQueue.h" -#include +#include "test/global/gmock.h" class CMockEventQueue : public IEventQueue { diff --git a/src/test/mock/synergy/MockKeyMap.h b/src/test/mock/synergy/MockKeyMap.h index a1c0b83e..c162b20e 100644 --- a/src/test/mock/synergy/MockKeyMap.h +++ b/src/test/mock/synergy/MockKeyMap.h @@ -20,7 +20,7 @@ #include "synergy/KeyMap.h" -#include +#include "test/global/gmock.h" class CMockKeyMap : public CKeyMap { diff --git a/src/test/mock/synergy/MockScreen.h b/src/test/mock/synergy/MockScreen.h index 0782b597..7c986db3 100644 --- a/src/test/mock/synergy/MockScreen.h +++ b/src/test/mock/synergy/MockScreen.h @@ -21,7 +21,7 @@ #include "synergy/Screen.h" -#include +#include "test/global/gmock.h" class CMockScreen : public CScreen { diff --git a/src/test/unittests/CMakeLists.txt b/src/test/unittests/CMakeLists.txt index 2c8e5028..65cf309b 100644 --- a/src/test/unittests/CMakeLists.txt +++ b/src/test/unittests/CMakeLists.txt @@ -17,6 +17,18 @@ file(GLOB_RECURSE headers "*.h") file(GLOB_RECURSE sources "*.cpp") +file(GLOB_RECURSE global_headers "../../test/global/*.h") +file(GLOB_RECURSE global_sources "../../test/global/*.cpp") + +list(APPEND headers ${global_headers}) +list(APPEND sources ${global_sources}) + +file(GLOB_RECURSE mock_headers "../../test/mock/*.h") +file(GLOB_RECURSE mock_sources "../../test/mock/*.cpp") + +list(APPEND headers ${mock_headers}) +list(APPEND sources ${mock_sources}) + include_directories( ../../ ../../lib/ diff --git a/src/test/unittests/Main.cpp b/src/test/unittests/Main.cpp index 7ec9c94c..a26a9edb 100644 --- a/src/test/unittests/Main.cpp +++ b/src/test/unittests/Main.cpp @@ -23,7 +23,7 @@ #include "arch/win32/ArchMiscWindows.h" #endif -#include +#include "test/global/gtest.h" int main(int argc, char **argv) diff --git a/src/test/unittests/client/ServerProxyTests.cpp b/src/test/unittests/client/ServerProxyTests.cpp index 2c47b5c7..8d3e4d41 100644 --- a/src/test/unittests/client/ServerProxyTests.cpp +++ b/src/test/unittests/client/ServerProxyTests.cpp @@ -24,7 +24,7 @@ #include "client/ServerProxy.h" #include "synergy/protocol_types.h" -#include +#include "test/global/gtest.h" using ::testing::_; using ::testing::Invoke; diff --git a/src/test/unittests/server/ClientProxyTests.cpp b/src/test/unittests/server/ClientProxyTests.cpp index 52076d06..87b00ec3 100644 --- a/src/test/unittests/server/ClientProxyTests.cpp +++ b/src/test/unittests/server/ClientProxyTests.cpp @@ -21,7 +21,7 @@ #include "test/mock/synergy/MockEventQueue.h" #include "server/ClientProxy1_4.h" -#include +#include "test/global/gtest.h" using ::testing::_; using ::testing::NiceMock; diff --git a/src/test/unittests/synergy/CryptoStreamTests.cpp b/src/test/unittests/synergy/CryptoStreamTests.cpp index f7619340..4aecc082 100644 --- a/src/test/unittests/synergy/CryptoStreamTests.cpp +++ b/src/test/unittests/synergy/CryptoStreamTests.cpp @@ -21,7 +21,7 @@ #include "io/CryptoStream.h" #include "io/CryptoOptions.h" -#include +#include "test/global/gtest.h" using ::testing::_; using ::testing::Invoke; diff --git a/src/test/unittests/synergy/KeyStateTests.cpp b/src/test/unittests/synergy/KeyStateTests.cpp index 862f5c52..509ed61b 100644 --- a/src/test/unittests/synergy/KeyStateTests.cpp +++ b/src/test/unittests/synergy/KeyStateTests.cpp @@ -17,11 +17,12 @@ */ #include "test/unittests/synergy/KeyStateTests.h" + #include "test/mock/synergy/MockEventQueue.h" #include "test/mock/synergy/MockKeyMap.h" -#include #include "test/global/gtest.h" +#include "test/global/gmock.h" using ::testing::_; using ::testing::NiceMock; diff --git a/src/test/unittests/synergy/KeyStateTests.h b/src/test/unittests/synergy/KeyStateTests.h index 92865a6b..31d26f71 100644 --- a/src/test/unittests/synergy/KeyStateTests.h +++ b/src/test/unittests/synergy/KeyStateTests.h @@ -20,7 +20,7 @@ #include "synergy/KeyState.h" -#include "gmock/gmock.h" +#include "test/global/gmock.h" class CMockKeyMap; class CMockEventQueue;