merged 1.4 r982:983 into trunk
This commit is contained in:
parent
627771cf13
commit
13c6c36107
|
@ -152,7 +152,7 @@ CMSWindowsClientTaskBarReceiver::runMenu(int x, int y)
|
||||||
SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE);
|
SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE);
|
||||||
HMENU logLevelMenu = GetSubMenu(menu, 3);
|
HMENU logLevelMenu = GetSubMenu(menu, 3);
|
||||||
CheckMenuRadioItem(logLevelMenu, 0, 6,
|
CheckMenuRadioItem(logLevelMenu, 0, 6,
|
||||||
CLOG->getFilter() - CLog::kERROR, MF_BYPOSITION);
|
CLOG->getFilter() - kERROR, MF_BYPOSITION);
|
||||||
int n = TrackPopupMenu(menu,
|
int n = TrackPopupMenu(menu,
|
||||||
TPM_NONOTIFY |
|
TPM_NONOTIFY |
|
||||||
TPM_RETURNCMD |
|
TPM_RETURNCMD |
|
||||||
|
@ -176,31 +176,31 @@ CMSWindowsClientTaskBarReceiver::runMenu(int x, int y)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_ERROR:
|
case IDC_TASKBAR_LOG_LEVEL_ERROR:
|
||||||
CLOG->setFilter(CLog::kERROR);
|
CLOG->setFilter(kERROR);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_WARNING:
|
case IDC_TASKBAR_LOG_LEVEL_WARNING:
|
||||||
CLOG->setFilter(CLog::kWARNING);
|
CLOG->setFilter(kWARNING);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_NOTE:
|
case IDC_TASKBAR_LOG_LEVEL_NOTE:
|
||||||
CLOG->setFilter(CLog::kNOTE);
|
CLOG->setFilter(kNOTE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_INFO:
|
case IDC_TASKBAR_LOG_LEVEL_INFO:
|
||||||
CLOG->setFilter(CLog::kINFO);
|
CLOG->setFilter(kINFO);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG:
|
case IDC_TASKBAR_LOG_LEVEL_DEBUG:
|
||||||
CLOG->setFilter(CLog::kDEBUG);
|
CLOG->setFilter(kDEBUG);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG1:
|
case IDC_TASKBAR_LOG_LEVEL_DEBUG1:
|
||||||
CLOG->setFilter(CLog::kDEBUG1);
|
CLOG->setFilter(kDEBUG1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG2:
|
case IDC_TASKBAR_LOG_LEVEL_DEBUG2:
|
||||||
CLOG->setFilter(CLog::kDEBUG2);
|
CLOG->setFilter(kDEBUG2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_QUIT:
|
case IDC_TASKBAR_QUIT:
|
||||||
|
|
|
@ -167,7 +167,7 @@ CMSWindowsServerTaskBarReceiver::runMenu(int x, int y)
|
||||||
SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE);
|
SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE);
|
||||||
HMENU logLevelMenu = GetSubMenu(menu, 3);
|
HMENU logLevelMenu = GetSubMenu(menu, 3);
|
||||||
CheckMenuRadioItem(logLevelMenu, 0, 6,
|
CheckMenuRadioItem(logLevelMenu, 0, 6,
|
||||||
CLOG->getFilter() - CLog::kERROR, MF_BYPOSITION);
|
CLOG->getFilter() - kERROR, MF_BYPOSITION);
|
||||||
int n = TrackPopupMenu(menu,
|
int n = TrackPopupMenu(menu,
|
||||||
TPM_NONOTIFY |
|
TPM_NONOTIFY |
|
||||||
TPM_RETURNCMD |
|
TPM_RETURNCMD |
|
||||||
|
@ -206,31 +206,31 @@ CMSWindowsServerTaskBarReceiver::runMenu(int x, int y)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_ERROR:
|
case IDC_TASKBAR_LOG_LEVEL_ERROR:
|
||||||
CLOG->setFilter(CLog::kERROR);
|
CLOG->setFilter(kERROR);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_WARNING:
|
case IDC_TASKBAR_LOG_LEVEL_WARNING:
|
||||||
CLOG->setFilter(CLog::kWARNING);
|
CLOG->setFilter(kWARNING);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_NOTE:
|
case IDC_TASKBAR_LOG_LEVEL_NOTE:
|
||||||
CLOG->setFilter(CLog::kNOTE);
|
CLOG->setFilter(kNOTE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_INFO:
|
case IDC_TASKBAR_LOG_LEVEL_INFO:
|
||||||
CLOG->setFilter(CLog::kINFO);
|
CLOG->setFilter(kINFO);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG:
|
case IDC_TASKBAR_LOG_LEVEL_DEBUG:
|
||||||
CLOG->setFilter(CLog::kDEBUG);
|
CLOG->setFilter(kDEBUG);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG1:
|
case IDC_TASKBAR_LOG_LEVEL_DEBUG1:
|
||||||
CLOG->setFilter(CLog::kDEBUG1);
|
CLOG->setFilter(kDEBUG1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG2:
|
case IDC_TASKBAR_LOG_LEVEL_DEBUG2:
|
||||||
CLOG->setFilter(CLog::kDEBUG2);
|
CLOG->setFilter(kDEBUG2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_QUIT:
|
case IDC_TASKBAR_QUIT:
|
||||||
|
|
|
@ -189,9 +189,9 @@ CArch::showConsole(bool showIfEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CArch::writeConsole(const char* str)
|
CArch::writeConsole(ELevel level, const char* str)
|
||||||
{
|
{
|
||||||
m_console->writeConsole(str);
|
m_console->writeConsole(level, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -77,7 +77,7 @@ public:
|
||||||
virtual void openConsole(const char*);
|
virtual void openConsole(const char*);
|
||||||
virtual void closeConsole();
|
virtual void closeConsole();
|
||||||
virtual void showConsole(bool showIfEmpty);
|
virtual void showConsole(bool showIfEmpty);
|
||||||
virtual void writeConsole(const char*);
|
virtual void writeConsole(ELevel, const char*);
|
||||||
|
|
||||||
// IArchDaemon overrides
|
// IArchDaemon overrides
|
||||||
virtual void installDaemon(const char* name,
|
virtual void installDaemon(const char* name,
|
||||||
|
|
|
@ -16,12 +16,16 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "CArchConsoleStd.h"
|
#include "CArchConsoleStd.h"
|
||||||
|
#include "CLog.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
void
|
void
|
||||||
CArchConsoleStd::writeConsole(const char* str)
|
CArchConsoleStd::writeConsole(ELevel level, const char* str)
|
||||||
{
|
{
|
||||||
// TODO: we need to use cerr also somehow
|
if ((level >= kFATAL) && (level <= kWARNING))
|
||||||
std::cout << str << std::endl;
|
std::cerr << str << std::endl;
|
||||||
|
else
|
||||||
|
std::cout << str << std::endl;
|
||||||
|
|
||||||
std::cout.flush();
|
std::cout.flush();
|
||||||
}
|
}
|
|
@ -29,5 +29,5 @@ public:
|
||||||
virtual void openConsole(const char* title) { }
|
virtual void openConsole(const char* title) { }
|
||||||
virtual void closeConsole() { }
|
virtual void closeConsole() { }
|
||||||
virtual void showConsole(bool) { }
|
virtual void showConsole(bool) { }
|
||||||
virtual void writeConsole(const char*);
|
virtual void writeConsole(ELevel level, const char*);
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#define IARCHCONSOLE_H
|
#define IARCHCONSOLE_H
|
||||||
|
|
||||||
#include "IInterface.h"
|
#include "IInterface.h"
|
||||||
|
#include "ELevel.h"
|
||||||
|
|
||||||
//! Interface for architecture dependent console output
|
//! Interface for architecture dependent console output
|
||||||
/*!
|
/*!
|
||||||
|
@ -59,7 +60,7 @@ public:
|
||||||
/*!
|
/*!
|
||||||
Writes the given string to the console, opening it if necessary.
|
Writes the given string to the console, opening it if necessary.
|
||||||
*/
|
*/
|
||||||
virtual void writeConsole(const char*) = 0;
|
virtual void writeConsole(ELevel, const char*) = 0;
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#define IARCHLOG_H
|
#define IARCHLOG_H
|
||||||
|
|
||||||
#include "IInterface.h"
|
#include "IInterface.h"
|
||||||
|
#include "ELevel.h"
|
||||||
|
|
||||||
//! Interface for architecture dependent logging
|
//! Interface for architecture dependent logging
|
||||||
/*!
|
/*!
|
||||||
|
@ -27,18 +28,6 @@ synergy. Each architecture must implement this interface.
|
||||||
*/
|
*/
|
||||||
class IArchLog : public IInterface {
|
class IArchLog : public IInterface {
|
||||||
public:
|
public:
|
||||||
//! Log levels
|
|
||||||
/*!
|
|
||||||
The logging priority levels in order of highest to lowest priority.
|
|
||||||
*/
|
|
||||||
enum ELevel {
|
|
||||||
kERROR, //!< For serious or fatal errors
|
|
||||||
kWARNING, //!< For minor errors and warnings
|
|
||||||
kNOTE, //!< For messages about notable events
|
|
||||||
kINFO, //!< For informational messages
|
|
||||||
kDEBUG //!< For debugging messages
|
|
||||||
};
|
|
||||||
|
|
||||||
//! @name manipulators
|
//! @name manipulators
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
|
|
|
@ -38,25 +38,6 @@ LOGC() provide convenient access.
|
||||||
*/
|
*/
|
||||||
class CLog {
|
class CLog {
|
||||||
public:
|
public:
|
||||||
//! Log levels
|
|
||||||
/*!
|
|
||||||
The logging priority levels in order of highest to lowest priority.
|
|
||||||
*/
|
|
||||||
enum ELevel {
|
|
||||||
kPRINT = -1, //!< For print only (no file or time)
|
|
||||||
kFATAL, //!< For fatal errors
|
|
||||||
kERROR, //!< For serious errors
|
|
||||||
kWARNING, //!< For minor errors and warnings
|
|
||||||
kNOTE, //!< For messages about notable events
|
|
||||||
kINFO, //!< For informational messages
|
|
||||||
kDEBUG, //!< For important debugging messages
|
|
||||||
kDEBUG1, //!< For verbosity +1 debugging messages
|
|
||||||
kDEBUG2, //!< For verbosity +2 debugging messages
|
|
||||||
kDEBUG3, //!< For verbosity +3 debugging messages
|
|
||||||
kDEBUG4, //!< For verbosity +4 debugging messages
|
|
||||||
kDEBUG5 //!< For verbosity +5 debugging messages
|
|
||||||
};
|
|
||||||
|
|
||||||
~CLog();
|
~CLog();
|
||||||
|
|
||||||
//! @name manipulators
|
//! @name manipulators
|
||||||
|
|
|
@ -34,6 +34,7 @@ set(inc
|
||||||
TMethodEventJob.h
|
TMethodEventJob.h
|
||||||
TMethodJob.h
|
TMethodJob.h
|
||||||
XBase.h
|
XBase.h
|
||||||
|
ELevel.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(src
|
set(src
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* synergy -- mouse and keyboard sharing utility
|
||||||
|
* Copyright (C) 2011 Chris Schoeneman, Nick Bolton, Sorin Sbarnea
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ELEVEL_H
|
||||||
|
#define ELEVEL_H
|
||||||
|
|
||||||
|
//! Log levels
|
||||||
|
/*!
|
||||||
|
The logging priority levels in order of highest to lowest priority.
|
||||||
|
*/
|
||||||
|
enum ELevel {
|
||||||
|
kPRINT = -1, //!< For print only (no file or time)
|
||||||
|
kFATAL, //!< For fatal errors
|
||||||
|
kERROR, //!< For serious errors
|
||||||
|
kWARNING, //!< For minor errors and warnings
|
||||||
|
kNOTE, //!< For messages about notable events
|
||||||
|
kINFO, //!< For informational messages
|
||||||
|
kDEBUG, //!< For important debugging messages
|
||||||
|
kDEBUG1, //!< For verbosity +1 debugging messages
|
||||||
|
kDEBUG2, //!< For verbosity +2 debugging messages
|
||||||
|
kDEBUG3, //!< For verbosity +3 debugging messages
|
||||||
|
kDEBUG4, //!< For verbosity +4 debugging messages
|
||||||
|
kDEBUG5 //!< For verbosity +5 debugging messages
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "IInterface.h"
|
#include "IInterface.h"
|
||||||
#include "CLog.h"
|
#include "CLog.h"
|
||||||
|
#include "ELevel.h"
|
||||||
|
|
||||||
//! Outputter interface
|
//! Outputter interface
|
||||||
/*!
|
/*!
|
||||||
|
@ -29,8 +30,6 @@ directly or indirectly.
|
||||||
*/
|
*/
|
||||||
class ILogOutputter : public IInterface {
|
class ILogOutputter : public IInterface {
|
||||||
public:
|
public:
|
||||||
typedef CLog::ELevel ELevel;
|
|
||||||
|
|
||||||
//! @name manipulators
|
//! @name manipulators
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
|
|
|
@ -92,8 +92,8 @@ CConsoleLogOutputter::show(bool showIfEmpty)
|
||||||
bool
|
bool
|
||||||
CConsoleLogOutputter::write(ELevel level, const char* msg)
|
CConsoleLogOutputter::write(ELevel level, const char* msg)
|
||||||
{
|
{
|
||||||
ARCH->writeConsole(msg);
|
ARCH->writeConsole(level, msg);
|
||||||
return true; // wtf?
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -138,31 +138,7 @@ CSystemLogOutputter::show(bool showIfEmpty)
|
||||||
bool
|
bool
|
||||||
CSystemLogOutputter::write(ELevel level, const char* msg)
|
CSystemLogOutputter::write(ELevel level, const char* msg)
|
||||||
{
|
{
|
||||||
IArchLog::ELevel archLogLevel;
|
ARCH->writeLog(level, msg);
|
||||||
switch (level) {
|
|
||||||
case CLog::kFATAL:
|
|
||||||
case CLog::kERROR:
|
|
||||||
archLogLevel = IArchLog::kERROR;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CLog::kWARNING:
|
|
||||||
archLogLevel = IArchLog::kWARNING;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CLog::kNOTE:
|
|
||||||
archLogLevel = IArchLog::kNOTE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CLog::kINFO:
|
|
||||||
archLogLevel = IArchLog::kINFO;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
archLogLevel = IArchLog::kDEBUG;
|
|
||||||
break;
|
|
||||||
|
|
||||||
};
|
|
||||||
ARCH->writeLog(archLogLevel, msg);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +242,7 @@ CFileLogOutputter::~CFileLogOutputter()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CFileLogOutputter::write(ILogOutputter::ELevel level, const char *message)
|
CFileLogOutputter::write(ELevel level, const char *message)
|
||||||
{
|
{
|
||||||
std::ofstream m_handle;
|
std::ofstream m_handle;
|
||||||
m_handle.open(m_fileName.c_str(), std::fstream::app);
|
m_handle.open(m_fileName.c_str(), std::fstream::app);
|
||||||
|
|
|
@ -80,6 +80,8 @@ public:
|
||||||
virtual SInt32 pollActiveGroup() const = 0;
|
virtual SInt32 pollActiveGroup() const = 0;
|
||||||
virtual void pollPressedKeys(KeyButtonSet& pressedKeys) const = 0;
|
virtual void pollPressedKeys(KeyButtonSet& pressedKeys) const = 0;
|
||||||
|
|
||||||
|
SInt32 getKeyState(KeyButton keyButton) { return m_keys[keyButton]; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef CKeyMap::Keystroke Keystroke;
|
typedef CKeyMap::Keystroke Keystroke;
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include "CArch.h"
|
#include "CArch.h"
|
||||||
|
#include "CLog.h"
|
||||||
|
|
||||||
#if SYSAPI_WIN32
|
#if SYSAPI_WIN32
|
||||||
#include "CArchMiscWindows.h"
|
#include "CArchMiscWindows.h"
|
||||||
|
@ -69,6 +70,8 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
CArch arch;
|
CArch arch;
|
||||||
|
|
||||||
|
CLOG->setFilter(kDEBUG2);
|
||||||
|
|
||||||
testing::InitGoogleTest(&argc, argv);
|
testing::InitGoogleTest(&argc, argv);
|
||||||
|
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
|
|
|
@ -14,8 +14,9 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
set(src
|
set(src
|
||||||
../../../tools/gtest-1.6.0/src/gtest_main.cc
|
Main.cpp
|
||||||
synergy/CClipboardTests.cpp
|
synergy/CClipboardTests.cpp
|
||||||
|
synergy/CKeyStateTests.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(inc
|
set(inc
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* synergy -- mouse and keyboard sharing utility
|
||||||
|
* Copyright (C) 2011 Chris Schoeneman, Nick Bolton, Sorin Sbarnea
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include "CArch.h"
|
||||||
|
#include "CLog.h"
|
||||||
|
|
||||||
|
#if SYSAPI_WIN32
|
||||||
|
#include "CArchMiscWindows.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
#if SYSAPI_WIN32
|
||||||
|
// HACK: shouldn't be needed, but logging fails without this.
|
||||||
|
CArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
CArch arch;
|
||||||
|
|
||||||
|
CLOG->setFilter(kDEBUG2);
|
||||||
|
|
||||||
|
testing::InitGoogleTest(&argc, argv);
|
||||||
|
|
||||||
|
return RUN_ALL_TESTS();
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
/*
|
||||||
|
* synergy -- mouse and keyboard sharing utility
|
||||||
|
* Copyright (C) 2011 Chris Schoeneman, Nick Bolton, Sorin Sbarnea
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include "CKeyState.h"
|
||||||
|
|
||||||
|
enum {
|
||||||
|
kAKey = 30
|
||||||
|
};
|
||||||
|
|
||||||
|
class CKeyStateImpl : public CKeyState
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
virtual SInt32 pollActiveGroup() const
|
||||||
|
{
|
||||||
|
throw std::exception("The method or operation is not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual KeyModifierMask pollActiveModifiers() const
|
||||||
|
{
|
||||||
|
throw std::exception("The method or operation is not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool fakeCtrlAltDel()
|
||||||
|
{
|
||||||
|
throw std::exception("The method or operation is not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void getKeyMap( CKeyMap& keyMap )
|
||||||
|
{
|
||||||
|
throw std::exception("The method or operation is not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void fakeKey( const Keystroke& keystroke )
|
||||||
|
{
|
||||||
|
throw std::exception("The method or operation is not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void pollPressedKeys( KeyButtonSet& pressedKeys ) const
|
||||||
|
{
|
||||||
|
throw std::exception("The method or operation is not implemented.");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST(CKeyStateTests, onKey_aKeyPressed_keyStateOne)
|
||||||
|
{
|
||||||
|
CKeyStateImpl keyState;
|
||||||
|
|
||||||
|
keyState.onKey(kAKey, true, KeyModifierAlt);
|
||||||
|
|
||||||
|
EXPECT_EQ(1, keyState.getKeyState(kAKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(CKeyStateTests, onKey_validButtonUp_keyStateZero)
|
||||||
|
{
|
||||||
|
CKeyStateImpl keyState;
|
||||||
|
|
||||||
|
keyState.onKey(0, true, KeyModifierAlt);
|
||||||
|
|
||||||
|
EXPECT_EQ(0, keyState.getKeyState(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(CKeyStateTests, onKey_bogusButtonDown_keyStateZero)
|
||||||
|
{
|
||||||
|
CKeyStateImpl keyState;
|
||||||
|
|
||||||
|
keyState.onKey(0, true, KeyModifierAlt);
|
||||||
|
|
||||||
|
EXPECT_EQ(0, keyState.getKeyState(0));
|
||||||
|
}
|
Loading…
Reference in New Issue