aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/global
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@ubuntu.com>2018-04-25 18:07:30 -0400
committerLibravatarUnit 193 <unit193@ubuntu.com>2018-04-25 18:07:30 -0400
commit9b1b081cfdb1c0fb6457278775e0823f8bc10f62 (patch)
treece8840148d8445055ba9e4f12263b2208f234c16 /src/test/global
Import Upstream version 2.0.0+dfsgupstream/2.0.0+dfsg
Diffstat (limited to 'src/test/global')
-rw-r--r--src/test/global/TestEventQueue.cpp53
-rw-r--r--src/test/global/TestEventQueue.h38
-rw-r--r--src/test/global/gmock.h32
-rw-r--r--src/test/global/gtest.h29
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>