diff options
author | Chase Douglas <chase.douglas@ubuntu.com> | 2011-12-07 14:46:28 -0800 |
---|---|---|
committer | Chase Douglas <chase.douglas@ubuntu.com> | 2011-12-07 14:46:28 -0800 |
commit | 016ff9329130266f10edd7f4828bf22e59a8c97f (patch) | |
tree | 45f5afb97b8e7d560b5e766365612c3683e3d85f | |
parent | 3aea1bbbbb7f7ab8a76cdbfc110fa9c5ed14ae25 (diff) |
Add xorg::testing::Test base test fixture
-rw-r--r-- | Makefile.am | 14 | ||||
-rw-r--r-- | include/xorg/gtest/test.h | 56 | ||||
-rw-r--r-- | src/test.cpp | 50 |
3 files changed, 115 insertions, 5 deletions
diff --git a/Makefile.am b/Makefile.am index 98ae76d..18aae5f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,16 +2,20 @@ lib_LTLIBRARIES = libxorg-gtest.la libxorg-gtest_main.la libxorg_gtest_la_SOURCES = \ src/environment.cpp \ - src/process.cpp + src/process.cpp \ + src/test.cpp libxorg_gtest_main_la_SOURCES = \ src/main.cpp -library_includedir=$(includedir)/xorg/gtest -library_include_HEADERS = include/xorg/gtest/environment.h include/xorg/gtest/process.h +library_includedir = $(includedir)/xorg/gtest +library_include_HEADERS = + include/xorg/gtest/environment.h \ + include/xorg/gtest/process.h \ + include/xorg/gtest/test.h -library_datadir=$(datadir)/xorg/gtest -library_data_DATA=conf/dummy.conf +library_datadir = $(datadir)/xorg/gtest +library_data_DATA = conf/dummy.conf libxorg_gtest_main_la_CPPFLAGS = $(AM_CPPFLAGS) -DDUMMY_CONF_PATH="\"$(library_datadir)/dummy.conf\"" diff --git a/include/xorg/gtest/test.h b/include/xorg/gtest/test.h new file mode 100644 index 0000000..c744c0d --- /dev/null +++ b/include/xorg/gtest/test.h @@ -0,0 +1,56 @@ +/***************************************************************************** + * + * utouch-frame - Touch Frame Library + * + * Copyright (C) 2011 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program 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 XORG_GTEST_TEST_H_ +#define XORG_GTEST_TEST_H_ + +#include <gtest/gtest.h> +#include <X11/Xlib.h> + +#include "utouch/frame.h" + +namespace xorg { +namespace testing { + +class Test : public ::testing::Test { + public: + Test(); + virtual ~Test(); + + virtual void SetUp(); + virtual void TearDown(); + + protected: + ::Display* Display() const; + + struct Private; + Private* d_; + + private: + // Disable copy c'tor, assignment operator + Test(const Test&); + Test& operator=(const Test&); +}; + +} // namespace testing +} // namespace xorg + +#endif // XORG_GTEST_TEST_H_ diff --git a/src/test.cpp b/src/test.cpp new file mode 100644 index 0000000..0ae31cf --- /dev/null +++ b/src/test.cpp @@ -0,0 +1,50 @@ +/***************************************************************************** + * + * utouch-frame - Touch Frame Library + * + * Copyright (C) 2011 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program 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 "xorg/gtest/test.h" + +#include <X11/Xlib.h> + +struct xorg::testing::Test::Private { + ::Display* display; +}; + +xorg::testing::Test::Test() : d_(new Private) { + d_->display = NULL; +} + +void xorg::testing::Test::SetUp() { + d_->display = XOpenDisplay(NULL); + ASSERT_TRUE(d_->display != NULL) << "Failed to open connection to display"; +} + +void xorg::testing::Test::TearDown() { + XCloseDisplay(d_->display); + d_->display = NULL; +} + +::Display* xorg::testing::Test::Display() const { + return d_->display; +} + +xorg::testing::Test::~Test() { + delete d_; +} |