| 1 |
/* |
| 2 |
* barrier -- mouse and keyboard sharing utility |
| 3 |
* Copyright (C) 2012-2016 Symless Ltd. |
| 4 |
* Copyright (C) 2011 Nick Bolton |
| 5 |
* |
| 6 |
* This package is free software; you can redistribute it and/or |
| 7 |
* modify it under the terms of the GNU General Public License |
| 8 |
* found in the file LICENSE that should have accompanied this file. |
| 9 |
* |
| 10 |
* This package is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
#include "test/mock/barrier/MockKeyMap.h" |
| 20 |
#include "test/mock/barrier/MockEventQueue.h" |
| 21 |
#include "platform/OSXKeyState.h" |
| 22 |
|
| 23 |
#include "test/global/gtest.h" |
| 24 |
#include "test/global/gmock.h" |
| 25 |
|
| 26 |
TEST(OSXKeyStateTests, mapModifiersFromOSX_OSXMask_returnBarrierMask) |
| 27 |
{ |
| 28 |
barrier::KeyMap keyMap; |
| 29 |
MockEventQueue eventQueue; |
| 30 |
OSXKeyState keyState(&eventQueue, keyMap); |
| 31 |
|
| 32 |
KeyModifierMask outMask = 0; |
| 33 |
|
| 34 |
UInt32 shiftMask = 0 | kCGEventFlagMaskShift; |
| 35 |
outMask = keyState.mapModifiersFromOSX(shiftMask); |
| 36 |
EXPECT_EQ(KeyModifierShift, outMask); |
| 37 |
|
| 38 |
UInt32 ctrlMask = 0 | kCGEventFlagMaskControl; |
| 39 |
outMask = keyState.mapModifiersFromOSX(ctrlMask); |
| 40 |
EXPECT_EQ(KeyModifierControl, outMask); |
| 41 |
|
| 42 |
UInt32 altMask = 0 | kCGEventFlagMaskAlternate; |
| 43 |
outMask = keyState.mapModifiersFromOSX(altMask); |
| 44 |
EXPECT_EQ(KeyModifierAlt, outMask); |
| 45 |
|
| 46 |
UInt32 cmdMask = 0 | kCGEventFlagMaskCommand; |
| 47 |
outMask = keyState.mapModifiersFromOSX(cmdMask); |
| 48 |
EXPECT_EQ(KeyModifierSuper, outMask); |
| 49 |
|
| 50 |
UInt32 capsMask = 0 | kCGEventFlagMaskAlphaShift; |
| 51 |
outMask = keyState.mapModifiersFromOSX(capsMask); |
| 52 |
EXPECT_EQ(KeyModifierCapsLock, outMask); |
| 53 |
|
| 54 |
UInt32 numMask = 0 | kCGEventFlagMaskNumericPad; |
| 55 |
outMask = keyState.mapModifiersFromOSX(numMask); |
| 56 |
EXPECT_EQ(KeyModifierNumLock, outMask); |
| 57 |
} |