aclocal/xorg-gtest.m4 | 14 - configure.ac | 2 data/Makefile.am | 4 data/X11/xorg.conf.d/99-virtual-test-devices.conf | 6 data/xorg/gtest/dummy.conf | 10 + debian/changelog | 15 + debian/libxorg-gtest-data.install | 1 examples/Makefile.am | 4 examples/xorg-gtest-example.cpp | 2 include/Makefile.am | 8 include/xorg/gtest/environment.h | 179 --------------------- include/xorg/gtest/evemu/device.h | 91 ---------- include/xorg/gtest/evemu/xorg-gtest_device.h | 91 ++++++++++ include/xorg/gtest/process.h | 166 ------------------- include/xorg/gtest/test.h | 104 ------------ include/xorg/gtest/xorg-gtest.h | 8 include/xorg/gtest/xorg-gtest_environment.h | 184 ++++++++++++++++++++++ include/xorg/gtest/xorg-gtest_process.h | 166 +++++++++++++++++++ include/xorg/gtest/xorg-gtest_test.h | 104 ++++++++++++ m4/gtest.m4 | 12 - src/Makefile-xorg-gtest.am | 3 src/device.cpp | 2 src/environment.cpp | 83 ++++++++- src/process.cpp | 2 src/test.cpp | 5 src/xorg-gtest_main.cpp | 58 ++++++ 26 files changed, 742 insertions(+), 582 deletions(-)
New commits: commit 135b3816d270a9370e23d7265b576598af6da0c0 Author: Chase Douglas <chase.doug...@canonical.com> Date: Fri Jun 8 12:38:59 2012 -0700 releasing version 0.3.0-0ubuntu1 diff --git a/debian/changelog b/debian/changelog index b766738..ed75b7f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -xorg-gtest (0.3.0-0ubuntu1) UNRELEASED; urgency=low +xorg-gtest (0.3.0-0ubuntu1) quantal; urgency=low * Ship usr/share/X11/xorg.conf.d/99-virtual-test-devices.conf * Update to version 0.3.0 @@ -11,7 +11,7 @@ xorg-gtest (0.3.0-0ubuntu1) UNRELEASED; urgency=low - Perform checks to see if dummy server could start before attempting - Enable the highest verbosity level for the dummy server log file - -- Chase Douglas <chase.doug...@ubuntu.com> Fri, 08 Jun 2012 12:10:26 -0700 + -- Chase Douglas <chase.doug...@ubuntu.com> Fri, 08 Jun 2012 12:36:58 -0700 xorg-gtest (0.2.0-0ubuntu2) precise; urgency=low commit 60d672c23db291a8f2f1438be45b7d04608ad540 Author: Chase Douglas <chase.doug...@canonical.com> Date: Fri Jun 8 12:15:39 2012 -0700 Update to version 0.3.0 * Update to version 0.3.0 - Prevent other X servers from grabbing test devices - Kill dummy server if test program dies - Provide a full X server layout to ensure the dummy video driver is used - Wait for dummy server to shut down before exiting - Namespace header filenames to prevent clashes with other headers - Better logging and error handling - Perform checks to see if dummy server could start before attempting - Enable the highest verbosity level for the dummy server log file diff --git a/debian/changelog b/debian/changelog index 680c4fc..b766738 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,17 @@ -xorg-gtest (0.2.0-0ubuntu3) UNRELEASED; urgency=low +xorg-gtest (0.3.0-0ubuntu1) UNRELEASED; urgency=low * Ship usr/share/X11/xorg.conf.d/99-virtual-test-devices.conf - - -- Chase Douglas <chase.doug...@ubuntu.com> Wed, 18 Apr 2012 13:54:02 -0700 + * Update to version 0.3.0 + - Prevent other X servers from grabbing test devices + - Kill dummy server if test program dies + - Provide a full X server layout to ensure the dummy video driver is used + - Wait for dummy server to shut down before exiting + - Namespace header filenames to prevent clashes with other headers + - Better logging and error handling + - Perform checks to see if dummy server could start before attempting + - Enable the highest verbosity level for the dummy server log file + + -- Chase Douglas <chase.doug...@ubuntu.com> Fri, 08 Jun 2012 12:10:26 -0700 xorg-gtest (0.2.0-0ubuntu2) precise; urgency=low commit 3774f91ba3722bd56b532dde549aef1df1749a51 Author: Chase Douglas <chase.doug...@canonical.com> Date: Fri Jun 8 12:01:23 2012 -0700 Release version 0.3.0 Signed-off-by: Chase Douglas <chase.doug...@canonical.com> diff --git a/configure.ac b/configure.ac index f3dd610..7d7b2e1 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ # Initialize Autoconf AC_PREREQ([2.60]) AC_INIT([Dummy X.org Testing Environment for Google Test], - [0.2.0], + [0.3.0], [], [xorg-gtest]) AC_CONFIG_SRCDIR([Makefile.am]) commit 9c8986c3d9854cb9a6f1f5dc39b8c16a1139ae91 Author: Peter Hutterer <peter.hutte...@who-t.net> Date: Tue Jun 5 14:49:34 2012 +1000 Set log verbosity to 10 Might as well get as much data as possible. Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> Reviewed-by: Chase Douglas <chase.doug...@canonical.com> Signed-off-by: Chase Douglas <chase.doug...@canonical.com> diff --git a/src/environment.cpp b/src/environment.cpp index a3a8ead..ca499ee 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -142,6 +142,7 @@ void xorg::testing::Environment::SetUp() { d_->process.Start(d_->path_to_server, d_->path_to_server.c_str(), display_string, + "-logverbose", "10", "-logfile", d_->path_to_log_file.c_str(), "-config", d_->path_to_conf.c_str(), NULL); commit 0c038b4c0a63f494eb7aec08baace7e750ab1b81 Author: Chase Douglas <chase.doug...@canonical.com> Date: Fri May 25 08:17:57 2012 -0700 Check if log file and old log file are writable before starting X server Otherwise, the server will fail to start and it won't be obvious what happened. Signed-off-by: Chase Douglas <chase.doug...@canonical.com> Reviewed-by: Peter Hutterer <peter.hutte...@who-t.net> diff --git a/src/environment.cpp b/src/environment.cpp index 68e05ce..a3a8ead 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -36,6 +36,7 @@ #include <csignal> #include <cstdlib> #include <cstring> +#include <fstream> #include <iostream> #include <stdexcept> @@ -114,6 +115,31 @@ void xorg::testing::Environment::SetUp() { throw std::runtime_error(message); } + /* The Xorg server won't start unless the log file and the old log file are + * writable. */ + std::ofstream log_test; + log_test.open(d_->path_to_log_file.c_str(), std::ofstream::out); + log_test.close(); + if (log_test.fail()) { + std::string message; + message += "X.org server log file "; + message += d_->path_to_log_file; + message += " is not writable."; + throw std::runtime_error(message); + } + + std::string old_log_file = d_->path_to_log_file.c_str(); + old_log_file += ".old"; + log_test.open(old_log_file.c_str(), std::ofstream::out); + log_test.close(); + if (log_test.fail()) { + std::string message; + message += "X.org old server log file "; + message += old_log_file; + message += " is not writable."; + throw std::runtime_error(message); + } + d_->process.Start(d_->path_to_server, d_->path_to_server.c_str(), display_string, "-logfile", d_->path_to_log_file.c_str(), commit 68b4ef7b5f100a14a5aee33d5c34ef8b29bafa3b Author: Chase Douglas <chase.doug...@canonical.com> Date: Fri May 25 07:40:49 2012 -0700 Check if a server is already running on the chosen display name Otherwise, our server will silently die and we will connect to the already running server without knowing. Signed-off-by: Chase Douglas <chase.doug...@canonical.com> Reviewed-by: Peter Hutterer <peter.hutte...@who-t.net> diff --git a/src/environment.cpp b/src/environment.cpp index 9e58e4a..68e05ce 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -104,6 +104,16 @@ void xorg::testing::Environment::SetUp() { static char display_string[6]; snprintf(display_string, 6, ":%d", d_->display); + Display* test_display = XOpenDisplay(display_string); + if (test_display) { + XCloseDisplay(test_display); + std::string message; + message += "A server is already running on "; + message += display_string; + message += "."; + throw std::runtime_error(message); + } + d_->process.Start(d_->path_to_server, d_->path_to_server.c_str(), display_string, "-logfile", d_->path_to_log_file.c_str(), @@ -113,7 +123,7 @@ void xorg::testing::Environment::SetUp() { Process::SetEnv("DISPLAY", display_string, true); for (int i = 0; i < 10; ++i) { - Display* test_display = XOpenDisplay(NULL); + test_display = XOpenDisplay(NULL); if (test_display) { XCloseDisplay(test_display); commit 2b5f29b84b87040be9ad6ce8d986b23bab253189 Author: Peter Hutterer <peter.hutte...@who-t.net> Date: Fri May 25 11:57:20 2012 +1000 XCloseDisplay(3) cannot handle NULL If the display failed to start, tearing it down with a NULL pointer causes a segfault. Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> Reviewed-by: Chase Douglas <chase.doug...@canonical.com> Signed-off-by: Chase Douglas <chase.doug...@canonical.com> diff --git a/src/test.cpp b/src/test.cpp index c2df5a7..f016f06 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -48,7 +48,8 @@ void xorg::testing::Test::SetUp() { } void xorg::testing::Test::TearDown() { - XCloseDisplay(d_->display); + if (d_->display) + XCloseDisplay(d_->display); d_->display = NULL; } commit 631aa80fe44b21dfac2938f2702d3ab15365dfba Author: Peter Hutterer <peter.hutte...@who-t.net> Date: Fri May 25 11:57:19 2012 +1000 Print the display we were trying to start up on. Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> Reviewed-by: Chase Douglas <chase.doug...@canonical.com> Signed-off-by: Chase Douglas <chase.doug...@canonical.com> diff --git a/src/environment.cpp b/src/environment.cpp index 38765ac..9e58e4a 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -124,8 +124,10 @@ void xorg::testing::Environment::SetUp() { int pid = waitpid(d_->process.Pid(), &status, WNOHANG); if (pid == d_->process.Pid()) { std::string message; - message += "X server failed to start. Ensure that the \"dummy\" video " - "driver is installed. If the X.org server is older than 1.12, " + message += "X server failed to start on display "; + message += display_string; + message += ". Ensure that the \"dummy\" video driver is installed. " + "If the X.org server is older than 1.12, " "tests will need to be run as root. Check "; message += d_->path_to_log_file; message += " for any errors"; commit 6a1174b8cdfc2079dd72209f49197d7a9c6555f1 Author: Peter Hutterer <peter.hutte...@who-t.net> Date: Thu May 24 13:13:28 2012 +1000 Update source files to use new headers introduced in e1c010f23272e61c28c73aa603b477ba6fbae875 Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> Reviewed-by: Chase Douglas <chase.doug...@canonical.com> Signed-off-by: Chase Douglas <chase.doug...@canonical.com> diff --git a/examples/xorg-gtest-example.cpp b/examples/xorg-gtest-example.cpp index 529fdda..6a2f662 100644 --- a/examples/xorg-gtest-example.cpp +++ b/examples/xorg-gtest-example.cpp @@ -1,4 +1,4 @@ -#include <xorg/gtest/test.h> +#include <xorg/gtest/xorg-gtest.h> using namespace xorg::testing; diff --git a/src/device.cpp b/src/device.cpp index 13d90ee..89eb8ea 100644 --- a/src/device.cpp +++ b/src/device.cpp @@ -25,7 +25,7 @@ * ******************************************************************************/ -#include "xorg/gtest/evemu/device.h" +#include "xorg/gtest/evemu/xorg-gtest_device.h" #include <fcntl.h> diff --git a/src/environment.cpp b/src/environment.cpp index d7d1c82..38765ac 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -25,8 +25,8 @@ * ******************************************************************************/ -#include "xorg/gtest/environment.h" -#include "xorg/gtest/process.h" +#include "xorg/gtest/xorg-gtest_environment.h" +#include "xorg/gtest/xorg-gtest_process.h" #include "defines.h" #include <sys/types.h> diff --git a/src/process.cpp b/src/process.cpp index 46d4b98..c11f12f 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -25,7 +25,7 @@ * ******************************************************************************/ -#include "xorg/gtest/process.h" +#include "xorg/gtest/xorg-gtest_process.h" #include <sys/types.h> #include <sys/wait.h> diff --git a/src/test.cpp b/src/test.cpp index 78158f9..c2df5a7 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -25,7 +25,7 @@ * ******************************************************************************/ -#include "xorg/gtest/test.h" +#include "xorg/gtest/xorg-gtest_test.h" #include <stdexcept> diff --git a/src/xorg-gtest_main.cpp b/src/xorg-gtest_main.cpp index 8953afa..bbf232b 100644 --- a/src/xorg-gtest_main.cpp +++ b/src/xorg-gtest_main.cpp @@ -31,7 +31,7 @@ #include <gtest/gtest.h> -#include "xorg/gtest/environment.h" +#include "xorg/gtest/xorg-gtest_environment.h" #include "defines.h" namespace { commit e1c010f23272e61c28c73aa603b477ba6fbae875 Author: Chase Douglas <chase.doug...@canonical.com> Date: Fri May 18 13:23:32 2012 -0700 Namespace xorg-gtest header filenames Due to the default automake compilation flags including -I. -I.., it is possible to pick up an xorg-gtest header like device.h instead of a project header. Namespacing the headers should resolve this issue. Users should be including xorg-gtest.h instead of individual headers, so this should not cause compilation failures. Signed-off-by: Chase Douglas <chase.doug...@canonical.com> Reviewed-by: Peter Hutterer <peter.hutte...@who-t.net> diff --git a/include/Makefile.am b/include/Makefile.am index 0256685..6b39d0b 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -24,8 +24,8 @@ # nobase_include_HEADERS = \ - xorg/gtest/environment.h \ - xorg/gtest/process.h \ - xorg/gtest/test.h \ - xorg/gtest/evemu/device.h \ + xorg/gtest/xorg-gtest_environment.h \ + xorg/gtest/xorg-gtest_process.h \ + xorg/gtest/xorg-gtest_test.h \ + xorg/gtest/evemu/xorg-gtest_device.h \ xorg/gtest/xorg-gtest.h diff --git a/include/xorg/gtest/environment.h b/include/xorg/gtest/environment.h deleted file mode 100644 index e113cd7..0000000 --- a/include/xorg/gtest/environment.h +++ /dev/null @@ -1,184 +0,0 @@ -/******************************************************************************* - * - * X testing environment - Google Test environment feat. dummy x server - * - * Copyright (C) 2011, 2012 Canonical Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - ******************************************************************************/ - -#ifndef XORG_GTEST_ENVIRONMENT_H -#define XORG_GTEST_ENVIRONMENT_H - -#include <memory> -#include <string> - -#include <gtest/gtest.h> - -namespace xorg { -namespace testing { - -/** - * \mainpage X.org Google %Test Framework - * - * Xorg-gtest makes it easy to write test cases - * for a dummy headless X.org server. It can also run tests - * using a running X11 server. - * - */ - -/** - * @class Environment environment.h xorg/gtest/environment.h - * - * Global Google %Test environment providing a dummy X server. - * - * Starts up a dummy X server for testing purposes. - * Either associate the environment manually - * with the overall testing framework like - * @code - * xorg::testing::Environment* environment = new xorg::testing::Environment; - * environment->set_server("Xorg"); - * environment->set_display(133); - * environment->set_conf_file("conf/dummy.conf"); - * environment->set_log_file("/tmp/MyDummyXorg.log"); - * testing::AddGlobalTestEnvironment(environment); - * @endcode - * or link to libxorg-gtest_main. - */ -class Environment : public ::testing::Environment { - public: - /** - * Constructs an object to provide a global X server dummy environment. - */ - Environment(); - - virtual ~Environment(); - - /** - * Sets the path where the server log file will be created. - * - * The path will be passed on to the server via the command line argument - * "-logfile". The default value is "/tmp/Xorg.GTest.log". - * - * @param path_to_log_file Path to server logfile. - */ - void set_log_file(const std::string& path_to_log_file); - - /** - * Returns the path where the server log file will be created. - * - * @return Path to server logfile. - */ - const std::string& log_file() const; - - /** - * Sets the path to the desired server configuration file. - * - * The path will be passed on to the server via the command line argument - * "-config". The default value is "[datadir]/xorg/gtest/dummy.conf". - * - * @param path_conf_file Path to a Xorg X server .conf file. - */ - void set_conf_file(const std::string& path_conf_file); - - /** - * Returns the path of the server configuration file to be used. - * - * @return File path of the server configuration currently set - */ - const std::string& conf_file() const; - - /** - * Sets the path to the server executable - * - * The default value is "Xorg". - * - * @param path_to_server Path to an X.org server executable - */ - void set_server(const std::string& path_to_server); - - /** - * Returns the path of the server executable to be used. - * - * @return Path to server executable. - */ - const std::string& server() const; - - /** - * Sets the display number that the server will use. - * - * The display number will be passed on to the server via the command line. - * The default value is 133. - * - * @param diplay_num A display number. - */ - void set_display(int display_num); - - /** - * Returns the display number of the server instance. - * - * @return Display number of the server. - */ - int display() const; - - /** - * Kill the dummy Xorg server with SIGKILL. - */ - void Kill(); - - protected: - /** - * Starts the dummy X server. - * - * Reimplemented from ::testing::Environment. See Google %Test documentation - * for details. - * - * @throws std::runtime_error if a dummy X server cannot be started. - * - * @post If successful: subsequent connections to the dummy X server succeed. - * @post If successful: %Environment variable DISPLAY contains the - * display port for connecting to the dummy X server. - */ - virtual void SetUp(); - - /** - * Stops the dummy X server. - * - * Reimplemented from ::testing::Environment. See Google %Test documentation - * for details. - * - * @post Dummy X server stopped. - */ - virtual void TearDown(); - - private: - struct Private; - std::auto_ptr<Private> d_; - - /* Disable copy constructor & assignment operator */ - Environment(const Environment&); - Environment& operator=(const Environment&); -}; - -} // namespace testing -} // namespace xorg - -#endif // XORG_GTEST_ENVIRONMENT_H diff --git a/include/xorg/gtest/evemu/device.h b/include/xorg/gtest/evemu/device.h deleted file mode 100644 index 4e456ce..0000000 --- a/include/xorg/gtest/evemu/device.h +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * - * X testing environment - Google Test environment feat. dummy x server - * - * Copyright (C) 2012 Canonical Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - ******************************************************************************/ - -#ifndef XORG_GTEST_EVEMU_DEVICE_H_ -#define XORG_GTEST_EVEMU_DEVICE_H_ - -#include <memory> -#include <string> - -extern "C" { - -#include <evemu.h> - -} // extern "C" - -namespace xorg { -namespace testing { -namespace evemu { - -/** - * @class Device device.h xorg/gtest/evemu/device.h - * - * uTouch-Evemu input device for replaying events through the Linux uinput - * evdev subsystem. - * - * Use the Recording class to play back a specific recording. - */ - -class Device { - public: - /** - * Create a new device context. - * - * @param [in] path Path to uTouch-Evemu device property file. - * - * @throws std::runtime_error if the device property file could not be found - * or the device could not be created. - */ - explicit Device(const std::string& path); - ~Device(); - - /** - * Play a uTouch-Evemu recording through the device. - * - * Plays the recording from the beginning through the end. This call will - * block until the recording has finished. - * - * @param [in] path Path to uTouch-Evemu recording file. - * - * @throws std::runtime_error if playback failed for any reason. - */ - void Play(const std::string& path) const; - - private: - struct Private; - std::auto_ptr<Private> d_; - - /* Disable copy constructor & assignment operator */ - Device(const Device&); - Device& operator=(const Device&); -}; - -} // namespace evemu -} // namespace testing -} // namespace xorg - -#endif // XORG_GTEST_EVEMU_DEVICE_H_ diff --git a/include/xorg/gtest/evemu/xorg-gtest_device.h b/include/xorg/gtest/evemu/xorg-gtest_device.h new file mode 100644 index 0000000..4e456ce --- /dev/null +++ b/include/xorg/gtest/evemu/xorg-gtest_device.h @@ -0,0 +1,91 @@ +/******************************************************************************* + * + * X testing environment - Google Test environment feat. dummy x server + * + * Copyright (C) 2012 Canonical Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + ******************************************************************************/ + +#ifndef XORG_GTEST_EVEMU_DEVICE_H_ +#define XORG_GTEST_EVEMU_DEVICE_H_ + +#include <memory> +#include <string> + +extern "C" { + +#include <evemu.h> + +} // extern "C" + +namespace xorg { +namespace testing { +namespace evemu { + +/** + * @class Device device.h xorg/gtest/evemu/device.h + * + * uTouch-Evemu input device for replaying events through the Linux uinput + * evdev subsystem. + * + * Use the Recording class to play back a specific recording. + */ + +class Device { + public: + /** + * Create a new device context. + * + * @param [in] path Path to uTouch-Evemu device property file. + * + * @throws std::runtime_error if the device property file could not be found + * or the device could not be created. + */ + explicit Device(const std::string& path); + ~Device(); + + /** + * Play a uTouch-Evemu recording through the device. + * + * Plays the recording from the beginning through the end. This call will + * block until the recording has finished. + * + * @param [in] path Path to uTouch-Evemu recording file. + * + * @throws std::runtime_error if playback failed for any reason. + */ + void Play(const std::string& path) const; + + private: + struct Private; + std::auto_ptr<Private> d_; + + /* Disable copy constructor & assignment operator */ + Device(const Device&); + Device& operator=(const Device&); +}; + +} // namespace evemu +} // namespace testing +} // namespace xorg + +#endif // XORG_GTEST_EVEMU_DEVICE_H_ diff --git a/include/xorg/gtest/process.h b/include/xorg/gtest/process.h deleted file mode 100644 index d7e1143..0000000 --- a/include/xorg/gtest/process.h +++ /dev/null @@ -1,166 +0,0 @@ -/******************************************************************************* - * - * X testing environment - Google Test environment feat. dummy x server - * - * Copyright (C) 2011, 2012 Canonical Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - ******************************************************************************/ - -#ifndef XORG_GTEST_PROCESS_H -#define XORG_GTEST_PROCESS_H - -#include <stdarg.h> - -#include <memory> -#include <string> - -namespace xorg { -namespace testing { - -/** - * @class Process test.h xorg/gtest/process.h - * - * Class that abstracts child process creation and termination. - * - * This class allows for forking, running and terminating child processes. - * In addition, manipulation of the child process' environment is supported. - * For example, starting an X server instance on display port 133 as a child - * process can be realized with the following code snippet: - * @code - * Process xorgServer; - * try { - * xorgServer.Start("Xorg", "Xorg", ":133"); - * } catch (const std::runtime_error&e) { - * std::cerr << "Problem starting the X server: " << e.what() << std::endl; - * } - * ... - * if (!xorgServer.Terminate()) { - * std::cerr << "Problem terminating server ... killing now ..." << std::endl; - * if (!xorgServer.Kill()) - * std::cerr << "Problem killing server" << std::endl; - * } - * @endcode - */ -class Process { - public: - /** - * Helper function to adjust the environment of the current process. - * - * @param [in] name Name of the environment variable. - * @param [in] value Value of the environment variable. - * @param [in] overwrite Whether to overwrite the value of existing env - * variables. - * - * @throws std::runtime_error if adjusting the environment does not succeed. - */ - static void SetEnv(const std::string& name, const std::string& value, - bool overwrite); - - /** - * Helper function to query the environment of the current process. - * - * @param [in] name The name of the environment variable. - * @param [out] exists If not NULL, the variable will be set to true if the - * environment variable exists and to false otherwise. - * @returns The value of the environment variable, or an empty string. - */ - static std::string GetEnv(const std::string& name, bool* exists = NULL); - - /** - * Creates a child-process that is in a terminated state. - */ - Process(); - - /** - * Starts a program as a child process. - * - * See 'man execvp' for further information on the variadic argument list. - * - * @param program The program to start. - * @param args Variadic list of arguments passed to the program. - * - * @throws std::runtime_error on failure. - * - * @post If successful: Child process forked and program started. - * @post If successful: Subsequent calls to Pid() return child process pid. - */ - void Start(const std::string& program, va_list args); - - /** - * Starts a program as a child process. - * - * Takes a variadic list of arguments passed to the program. - * See 'man execvp' for further information on the variadic argument list. - * - * @param program The program to start. - * - * @throws std::runtime_error on failure. - * - * @post If successful: Child process forked and program started. - * @post If successful: Subsequent calls to Pid() return child process pid. - */ - void Start(const std::string& program, ...); - - /** - * Terminates (SIGTERM) this child process. - * - * @throws std::runtime_error if child tries to terminate itself. - * - * @returns true if termination succeeded, false otherwise. - * - * @post If successful: Child process terminated. - * @post If successful: Subsequent calls to Pid() return -1. - */ - bool Terminate(); - - /** - * Kills (SIGKILL) this child process. - * - * @throws std::runtime_error if child tries to kill itself. - * - * @returns true if kill succeeded, false otherwise. - * - * @post If successful: Child process killed. - * @post If successful: Subsequent calls to Pid() return -1. - */ - bool Kill(); - - /** - * Accesses the pid of the child process. - * - * @returns The pid of the child process or -1. - */ - pid_t Pid() const; - - private: - struct Private; - std::auto_ptr<Private> d_; - - /* Disable copy constructor, assignment operator */ - Process(const Process&); - Process& operator=(const Process&); -}; - -} // testing -} // xorg - -#endif // XORG_GTEST_PROCESS_H diff --git a/include/xorg/gtest/test.h b/include/xorg/gtest/test.h deleted file mode 100644 index 093890b..0000000 --- a/include/xorg/gtest/test.h +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * - * X testing environment - Google Test environment feat. dummy x server - * - * Copyright (C) 2011, 2012 Canonical Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. -- To UNSUBSCRIBE, email to debian-x-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/e1sd51c-0007pm...@vasks.debian.org