diff options
Diffstat (limited to 'src/test/global')
| -rw-r--r-- | src/test/global/TestEventQueue.cpp | 53 | ||||
| -rw-r--r-- | src/test/global/TestEventQueue.h | 38 | ||||
| -rw-r--r-- | src/test/global/gmock.h | 32 | ||||
| -rw-r--r-- | src/test/global/gtest.h | 29 |
4 files changed, 152 insertions, 0 deletions
diff --git a/src/test/global/TestEventQueue.cpp b/src/test/global/TestEventQueue.cpp new file mode 100644 index 0000000..d202922 --- /dev/null +++ b/src/test/global/TestEventQueue.cpp @@ -0,0 +1,53 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2013-2016 Symless 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 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 <http://www.gnu.org/licenses/>. + */ + +#include "test/global/TestEventQueue.h" + +#include "base/Log.h" +#include "base/TMethodEventJob.h" +#include "base/SimpleEventQueueBuffer.h" +#include "common/stdexcept.h" + +void +TestEventQueue::raiseQuitEvent() +{ + addEvent(Event(Event::kQuit)); +} + +void +TestEventQueue::initQuitTimeout(double timeout) +{ + assert(m_quitTimeoutTimer == nullptr); + m_quitTimeoutTimer = newOneShotTimer(timeout, NULL); + adoptHandler(Event::kTimer, m_quitTimeoutTimer, + new TMethodEventJob<TestEventQueue>( + this, &TestEventQueue::handleQuitTimeout)); +} + +void +TestEventQueue::cleanupQuitTimeout() +{ + removeHandler(Event::kTimer, m_quitTimeoutTimer); + delete m_quitTimeoutTimer; + m_quitTimeoutTimer = nullptr; +} + +void +TestEventQueue::handleQuitTimeout(const Event&, void* vclient) +{ + throw std::runtime_error("test event queue timeout"); +} diff --git a/src/test/global/TestEventQueue.h b/src/test/global/TestEventQueue.h new file mode 100644 index 0000000..a6cf0ca --- /dev/null +++ b/src/test/global/TestEventQueue.h @@ -0,0 +1,38 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2013-2016 Symless 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 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 <http://www.gnu.org/licenses/>. + */ + +#pragma once + +#include "base/EventQueue.h" + +class EventQueueTimer; + +class TestEventQueue : public EventQueue { +public: + TestEventQueue() : m_quitTimeoutTimer(nullptr) { } + + void handleQuitTimeout(const Event&, void* vclient); + void raiseQuitEvent(); + void initQuitTimeout(double timeout); + void cleanupQuitTimeout(); + +private: + void timeoutThread(void*); + +private: + EventQueueTimer* m_quitTimeoutTimer; +}; diff --git a/src/test/global/gmock.h b/src/test/global/gmock.h new file mode 100644 index 0000000..64597f4 --- /dev/null +++ b/src/test/global/gmock.h @@ -0,0 +1,32 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2014-2016 Symless 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 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 <http://www.gnu.org/licenses/>. + */ + +#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 <gmock/gmock.h> diff --git a/src/test/global/gtest.h b/src/test/global/gtest.h new file mode 100644 index 0000000..0b2acbc --- /dev/null +++ b/src/test/global/gtest.h @@ -0,0 +1,29 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2014-2016 Symless 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 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 <http://www.gnu.org/licenses/>. + */ + +#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 + +// gtest has a warning on osx106 (signed/unsigned int compare). +#include <gtest/gtest.h> |
