diff options
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | examples/Makefile.am | 25 | ||||
-rw-r--r-- | examples/xorg-gtest.cpp | 39 | ||||
-rw-r--r-- | include/xorg/gtest/environment.h | 1 | ||||
-rw-r--r-- | include/xorg/gtest/test.h | 2 | ||||
-rw-r--r-- | src/environment.cpp | 4 | ||||
-rw-r--r-- | src/test.cpp | 2 |
8 files changed, 75 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am index 021d2a0..dcd06a3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,7 +11,7 @@ libxorg_gtest_main_la_SOURCES = \ src/main.cpp library_includedir = $(includedir)/xorg/gtest -library_include_HEADERS = +library_include_HEADERS = \ include/xorg/gtest/environment.h \ include/xorg/gtest/process.h \ include/xorg/gtest/test.h diff --git a/configure.ac b/configure.ac index 7445eef..266f1d8 100644 --- a/configure.ac +++ b/configure.ac @@ -43,6 +43,6 @@ AC_CONFIG_FILES([Makefile AC_SUBST(AM_CPPFLAGS, "-Wall -Werror") -AC_CONFIG_FILES([doc/Makefile]) +AC_CONFIG_FILES([doc/Makefile examples/Makefile]) AC_OUTPUT diff --git a/examples/Makefile.am b/examples/Makefile.am new file mode 100644 index 0000000..9bb5ee7 --- /dev/null +++ b/examples/Makefile.am @@ -0,0 +1,25 @@ +# +# @file examples/Makefile.am +# @brief automake recipe for the xorg-gtest examples +# +# Copyright 2011 Canonical, Ltd. +# +# This file is part of the utouch-geis library. This library is free software; +# you can redistribute it and/or modify it under the terms of the GNU Lesser +# General Public License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# This library 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 Lesser 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/>. +# + +noinst_PROGRAMS = xorg_gtest_example + +xorg_gtest_example_SOURCES = xorg-gtest.cpp + +xorg_gtest_example_LDFLAGS = -lxorg-gtest -lxorg-gtest_main -lgtest -lpthread -lX11
\ No newline at end of file diff --git a/examples/xorg-gtest.cpp b/examples/xorg-gtest.cpp new file mode 100644 index 0000000..ec116fe --- /dev/null +++ b/examples/xorg-gtest.cpp @@ -0,0 +1,39 @@ +/***************************************************************************** + * + * X testing environment - Google Test environment feat. dummy x server + * + * 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> + +using namespace xorg::testing; + +/** + * @example xorg-gtest.cpp + * + * This is an example for using the fixture + * xorg::testing::Test for your own tests. Please + * make sure that you have the X.org dummy display + * driver installed on your system and that you execute + * the test with root privileges. + */ +TEST_F(Test, DummyXorgServerTest) { + + EXPECT_NE(0, DefaultRootWindow(Display())); + +} diff --git a/include/xorg/gtest/environment.h b/include/xorg/gtest/environment.h index 41f44e4..8d3901b 100644 --- a/include/xorg/gtest/environment.h +++ b/include/xorg/gtest/environment.h @@ -70,6 +70,7 @@ class Environment : public ::testing::Environment { Environment(const std::string& path_to_conf, const std::string& path_to_server = "Xorg", int display = 133); + virtual ~Environment(); /** * Starts the dummy X server. * diff --git a/include/xorg/gtest/test.h b/include/xorg/gtest/test.h index edfa4fe..64e1dda 100644 --- a/include/xorg/gtest/test.h +++ b/include/xorg/gtest/test.h @@ -47,6 +47,8 @@ class Test : public ::testing::Test { Test(); + virtual ~Test(); + /** * Tries to connect to an X server instance. * diff --git a/src/environment.cpp b/src/environment.cpp index 8f8078f..0cc7bc2 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -51,6 +51,10 @@ xorg::testing::Environment::Environment(const std::string& path_to_conf, : d_(new Private(path_to_conf, path_to_server, display)) { } +xorg::testing::Environment::~Environment() { + +} + void xorg::testing::Environment::SetUp() { static char display_string[6]; snprintf(display_string, 6, ":%d", d_->display); diff --git a/src/test.cpp b/src/test.cpp index b971609..83c1cbd 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -33,6 +33,8 @@ xorg::testing::Test::Test() : d_(new Private) { d_->display = NULL; } +xorg::testing::Test::~Test() {} + void xorg::testing::Test::SetUp() { d_->display = XOpenDisplay(NULL); if (!d_->display) |