diff --git a/src/test/unittests/CMakeLists.txt b/src/test/unittests/CMakeLists.txt index ba919a16..65d05d80 100644 --- a/src/test/unittests/CMakeLists.txt +++ b/src/test/unittests/CMakeLists.txt @@ -17,6 +17,10 @@ file(GLOB_RECURSE headers "*.h") file(GLOB_RECURSE sources "*.cpp") +file(GLOB_RECURSE remove_platform "platform/*") +list(REMOVE_ITEM headers ${remove_platform}) +list(REMOVE_ITEM sources ${remove_platform}) + file(GLOB_RECURSE global_headers "../../test/global/*.h") file(GLOB_RECURSE global_sources "../../test/global/*.cpp") @@ -29,6 +33,21 @@ file(GLOB_RECURSE mock_sources "../../test/mock/*.cpp") list(APPEND headers ${mock_headers}) list(APPEND sources ${mock_sources}) +# platform +if (WIN32) + file(GLOB platform_sources "platform/MSWindows*.cpp") + file(GLOB platform_headers "platform/MSWindows*.h") +elseif (APPLE) + file(GLOB platform_sources "platform/OSX*.cpp") + file(GLOB platform_headers "platform/OSX*.h") +elseif (UNIX) + file(GLOB platform_sources "platform/XWindows*.cpp") + file(GLOB platform_headers "platform/XWindows*.h") +endif() + +list(APPEND sources ${platform_headers}) +list(APPEND headers ${platform_sources}) + include_directories( ../../ ../../lib/ diff --git a/src/test/unittests/platform/OSXKeyStateTests.cpp b/src/test/unittests/platform/OSXKeyStateTests.cpp new file mode 100644 index 00000000..c5190e83 --- /dev/null +++ b/src/test/unittests/platform/OSXKeyStateTests.cpp @@ -0,0 +1,57 @@ +/* + * synergy -- mouse and keyboard sharing utility + * Copyright (C) 2012 Synergy Si 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 . + */ + +#include "test/mock/synergy/MockKeyMap.h" +#include "test/mock/synergy/MockEventQueue.h" +#include "platform/OSXKeyState.h" + +#include "test/global/gtest.h" +#include "test/global/gmock.h" + +TEST(OSXKeyStateTests, mapModifiersFromOSX_OSXMask_returnSynergyMask) +{ + synergy::KeyMap keyMap; + MockEventQueue eventQueue; + OSXKeyState keyState(&eventQueue, keyMap); + + KeyModifierMask outMask = 0; + + UInt32 shiftMask = 0 | kCGEventFlagMaskShift; + outMask = keyState.mapModifiersFromOSX(shiftMask); + EXPECT_EQ(KeyModifierShift, outMask); + + UInt32 ctrlMask = 0 | kCGEventFlagMaskControl; + outMask = keyState.mapModifiersFromOSX(ctrlMask); + EXPECT_EQ(KeyModifierControl, outMask); + + UInt32 altMask = 0 | kCGEventFlagMaskAlternate; + outMask = keyState.mapModifiersFromOSX(altMask); + EXPECT_EQ(KeyModifierAlt, outMask); + + UInt32 cmdMask = 0 | kCGEventFlagMaskCommand; + outMask = keyState.mapModifiersFromOSX(cmdMask); + EXPECT_EQ(KeyModifierSuper, outMask); + + UInt32 capsMask = 0 | kCGEventFlagMaskAlphaShift; + outMask = keyState.mapModifiersFromOSX(capsMask); + EXPECT_EQ(KeyModifierCapsLock, outMask); + + UInt32 numMask = 0 | kCGEventFlagMaskNumericPad; + outMask = keyState.mapModifiersFromOSX(numMask); + EXPECT_EQ(KeyModifierNumLock, outMask); +}