• Main Page
  • Classes
  • Files
  • File List

CKeyStateTests.h

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2012 Bolton Software Ltd.
00004  * Copyright (C) 2011 Nick Bolton
00005  * 
00006  * This package is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * found in the file COPYING that should have accompanied this file.
00009  * 
00010  * This package is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017  */
00018 
00019 #ifndef CKEYSTATETESTS_H
00020 #define CKEYSTATETESTS_H
00021 
00022 #include "CKeyState.h"
00023 #include "gmock/gmock.h"
00024 
00025 class CMockKeyMap;
00026 class CMockEventQueue;
00027 
00028 // NOTE: do not mock methods that are not pure virtual. this mock exists only
00029 // to provide an implementation of the CKeyState abstract class.
00030 class CMockKeyState : public CKeyState
00031 {
00032 public:
00033     CMockKeyState() : CKeyState()
00034     {
00035     }
00036 
00037     CMockKeyState(const CMockEventQueue& eventQueue, const CMockKeyMap& keyMap) :
00038         CKeyState((IEventQueue&)eventQueue, (CKeyMap&)keyMap)
00039     {
00040     }
00041 
00042     MOCK_CONST_METHOD0(pollActiveGroup, SInt32());
00043     MOCK_CONST_METHOD0(pollActiveModifiers, KeyModifierMask());
00044     MOCK_METHOD0(fakeCtrlAltDel, bool());
00045     MOCK_METHOD1(getKeyMap, void(CKeyMap&));
00046     MOCK_METHOD1(fakeKey, void(const Keystroke&));
00047     MOCK_CONST_METHOD1(pollPressedKeys, void(KeyButtonSet&));
00048 };
00049 
00050 typedef ::testing::NiceMock<CMockKeyState> CKeyStateImpl;
00051 
00052 typedef UInt32 KeyID;
00053 
00054 typedef void (*ForeachKeyCallback)(
00055         KeyID, SInt32 group, CKeyMap::KeyItem&, void* userData);
00056 
00057 void
00058 stubPollPressedKeys(IKeyState::KeyButtonSet& pressedKeys);
00059 
00060 void
00061 assertMaskIsOne(ForeachKeyCallback cb, void* userData);
00062 
00063 const CKeyMap::KeyItem*
00064 stubMapKey(
00065     CKeyMap::Keystrokes& keys, KeyID id, SInt32 group,
00066     CKeyMap::ModifierToKeys& activeModifiers,
00067     KeyModifierMask& currentState,
00068     KeyModifierMask desiredMask,
00069     bool isAutoRepeat);
00070 
00071 CKeyMap::Keystroke s_stubKeystroke(1, false, false);
00072 CKeyMap::KeyItem s_stubKeyItem;
00073 
00074 #endif

Generated on Sat May 25 2013 00:00:04 for Synergy by  doxygen 1.7.1