[PATCH xorg-gtest] Rename headers to use dashes only

Peter Hutterer peter.hutterer at who-t.net
Mon Jul 2 20:17:28 PDT 2012


Mixing dashes and spaces in xorg-gtest_foobar.h is a painful naming
convention. Use dashes only instead, and provide compat headers plus a
warning for those using the old header files.

Those users should be using xorg-gtest.h anyway.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
If the diff looks confusing, it is merely a
$> git mv xorg-gtest_device.h xorg-gtest-device.h
for all headers. The compat headers all now have stanza like this:
+#warning "This header is deprecated. Include xorg-gtest-device.h instead"
+#include "xorg-gtest-device.h"

The rest is the required search/replace of header file names inside the
other files.

 include/Makefile.am                          |   14 +-
 include/xorg/gtest/evemu/xorg-gtest-device.h |   91 +++++++++++++
 include/xorg/gtest/evemu/xorg-gtest_device.h |   93 +------------
 include/xorg/gtest/xorg-gtest-environment.h  |  184 +++++++++++++++++++++++++
 include/xorg/gtest/xorg-gtest-process.h      |  166 +++++++++++++++++++++++
 include/xorg/gtest/xorg-gtest-test.h         |  104 ++++++++++++++
 include/xorg/gtest/xorg-gtest.h              |    8 +-
 include/xorg/gtest/xorg-gtest_device.h       |    2 +
 include/xorg/gtest/xorg-gtest_environment.h  |  186 +-------------------------
 include/xorg/gtest/xorg-gtest_process.h      |  168 +----------------------
 include/xorg/gtest/xorg-gtest_test.h         |  106 +--------------
 src/device.cpp                               |    2 +-
 src/environment.cpp                          |    4 +-
 src/process.cpp                              |    2 +-
 src/test.cpp                                 |    2 +-
 src/xorg-gtest_main.cpp                      |    2 +-
 16 files changed, 576 insertions(+), 558 deletions(-)
 create mode 100644 include/xorg/gtest/evemu/xorg-gtest-device.h
 create mode 100644 include/xorg/gtest/xorg-gtest-environment.h
 create mode 100644 include/xorg/gtest/xorg-gtest-process.h
 create mode 100644 include/xorg/gtest/xorg-gtest-test.h
 create mode 100644 include/xorg/gtest/xorg-gtest_device.h

diff --git a/include/Makefile.am b/include/Makefile.am
index 6b39d0b..9ff5f2a 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -23,9 +23,17 @@
 # SOFTWARE.
 #
 
-nobase_include_HEADERS = \
+# compat headers, to be dropped in the future
+compat_headers =  \
 	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
+	xorg/gtest/evemu/xorg-gtest_device.h
+
+nobase_include_HEADERS = \
+	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 \
+	$(compat_headers)
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..5f8faa2
--- /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 xorg-gtest_device.h xorg/gtest/evemu/xorg-gtest_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
index 5f8faa2..464c90d 100644
--- a/include/xorg/gtest/evemu/xorg-gtest_device.h
+++ b/include/xorg/gtest/evemu/xorg-gtest_device.h
@@ -1,91 +1,2 @@
-/*******************************************************************************
- *
- * 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 xorg-gtest_device.h xorg/gtest/evemu/xorg-gtest_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_
+#warning "This header is deprecated. Include xorg-gtest-device.h instead"
+#include "xorg-gtest-device.h"
diff --git a/include/xorg/gtest/xorg-gtest-environment.h b/include/xorg/gtest/xorg-gtest-environment.h
new file mode 100644
index 0000000..de680ca
--- /dev/null
+++ b/include/xorg/gtest/xorg-gtest-environment.h
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ *
+ * 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 xorg-gtest-environment.h environment.h xorg/gtest/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 display_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/xorg-gtest-process.h b/include/xorg/gtest/xorg-gtest-process.h
new file mode 100644
index 0000000..47aefcf
--- /dev/null
+++ b/include/xorg/gtest/xorg-gtest-process.h
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ *
+ * 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 xorg-gtest-process.h xorg/gtest/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/xorg-gtest-test.h b/include/xorg/gtest/xorg-gtest-test.h
new file mode 100644
index 0000000..3b78a17
--- /dev/null
+++ b/include/xorg/gtest/xorg-gtest-test.h
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ *
+ * 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_TEST_H_
+#define XORG_GTEST_TEST_H_
+
+#include <memory>
+
+#include <gtest/gtest.h>
+#include <X11/Xlib.h>
+
+namespace xorg {
+namespace testing {
+
+/**
+ * @class Test xorg-gtest-test.h xorg/gtest/xorg-gtest-test.h
+ *
+ * Google %Test fixture providing an Xlib connection to an X11 server.
+ *
+ * Sets up and tears down an XLib connection to an X11 server.
+ * Rely on Google %Test's TEST_F macro to use this fixture for your
+ * own tests or subclass it and override the SetUp and TearDown
+ * methods.
+ *
+ * @remark The display port is read from the environment variable DISPLAY.
+ */
+class Test : public ::testing::Test {
+ public:
+
+  Test();
+
+  virtual ~Test();
+
+ protected:
+  /**
+   * Tries to connect to an X server instance.
+   *
+   * Fails if no X server is running. Updates the display object.
+   * Reimplemented from ::testing::Test. See Google %Test documentation for
+   * details.
+   *
+   * @post Subsequent calls to Display() return a valid pointer or NULL if an error occured.
+   *
+   * @throws std::runtime_error if no X server is running.
+   */
+  virtual void SetUp();
+
+  /**
+   * Closes the display.
+   *
+   * Reimplemented from ::testing::Test. See Google %Test documentation for
+   * details.
+   *
+   * @post Subsequent calls to Display() return NULL.
+   */
+  virtual void TearDown();
+
+  /**
+   * Accesses the display representing an Xlib connection.
+   *
+   * Accessible by subclasses and test cases relying on this fixture.
+   *
+   * @returns Pointer to a display or NULL.
+   */
+  ::Display* Display() const;
+
+  /** @cond Implementation */
+  struct Private;
+  std::auto_ptr<Private> d_;
+  /** @endcond Implementation */
+ 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/include/xorg/gtest/xorg-gtest.h b/include/xorg/gtest/xorg-gtest.h
index deb2ad7..9d57e9e 100644
--- a/include/xorg/gtest/xorg-gtest.h
+++ b/include/xorg/gtest/xorg-gtest.h
@@ -25,10 +25,10 @@
  *
  ******************************************************************************/
 
-#include "xorg-gtest_environment.h"
-#include "xorg-gtest_process.h"
-#include "xorg-gtest_test.h"
+#include "xorg-gtest-environment.h"
+#include "xorg-gtest-process.h"
+#include "xorg-gtest-test.h"
 
 #ifdef HAVE_EVEMU
-#include "evemu/xorg-gtest_device.h"
+#include "evemu/xorg-gtest-device.h"
 #endif
diff --git a/include/xorg/gtest/xorg-gtest_device.h b/include/xorg/gtest/xorg-gtest_device.h
new file mode 100644
index 0000000..464c90d
--- /dev/null
+++ b/include/xorg/gtest/xorg-gtest_device.h
@@ -0,0 +1,2 @@
+#warning "This header is deprecated. Include xorg-gtest-device.h instead"
+#include "xorg-gtest-device.h"
diff --git a/include/xorg/gtest/xorg-gtest_environment.h b/include/xorg/gtest/xorg-gtest_environment.h
index 80982c6..50000cd 100644
--- a/include/xorg/gtest/xorg-gtest_environment.h
+++ b/include/xorg/gtest/xorg-gtest_environment.h
@@ -1,184 +1,2 @@
-/*******************************************************************************
- *
- * 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 xorg-gtest_environment.h environment.h xorg/gtest/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 display_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
+#warning "This header is deprecated. Include xorg-gtest-environment.h instead"
+#include "xorg-gtest-environment.h"
diff --git a/include/xorg/gtest/xorg-gtest_process.h b/include/xorg/gtest/xorg-gtest_process.h
index 476c0ad..2175a27 100644
--- a/include/xorg/gtest/xorg-gtest_process.h
+++ b/include/xorg/gtest/xorg-gtest_process.h
@@ -1,166 +1,2 @@
-/*******************************************************************************
- *
- * 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 xorg-gtest_process.h xorg/gtest/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
+#warning "This header is deprecated. Include xorg-gtest-process.h instead"
+#include "xorg-gtest-process.h"
diff --git a/include/xorg/gtest/xorg-gtest_test.h b/include/xorg/gtest/xorg-gtest_test.h
index a3cd3b9..4c21a36 100644
--- a/include/xorg/gtest/xorg-gtest_test.h
+++ b/include/xorg/gtest/xorg-gtest_test.h
@@ -1,104 +1,2 @@
-/*******************************************************************************
- *
- * 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_TEST_H_
-#define XORG_GTEST_TEST_H_
-
-#include <memory>
-
-#include <gtest/gtest.h>
-#include <X11/Xlib.h>
-
-namespace xorg {
-namespace testing {
-
-/**
- * @class Test xorg-gtest_test.h xorg/gtest/xorg-gtest_test.h
- *
- * Google %Test fixture providing an Xlib connection to an X11 server.
- *
- * Sets up and tears down an XLib connection to an X11 server.
- * Rely on Google %Test's TEST_F macro to use this fixture for your
- * own tests or subclass it and override the SetUp and TearDown
- * methods.
- *
- * @remark The display port is read from the environment variable DISPLAY.
- */
-class Test : public ::testing::Test {
- public:
-
-  Test();
-
-  virtual ~Test();
-
- protected:
-  /**
-   * Tries to connect to an X server instance.
-   *
-   * Fails if no X server is running. Updates the display object.
-   * Reimplemented from ::testing::Test. See Google %Test documentation for
-   * details.
-   *
-   * @post Subsequent calls to Display() return a valid pointer or NULL if an error occured.
-   *
-   * @throws std::runtime_error if no X server is running.
-   */
-  virtual void SetUp();
-
-  /**
-   * Closes the display.
-   *
-   * Reimplemented from ::testing::Test. See Google %Test documentation for
-   * details.
-   *
-   * @post Subsequent calls to Display() return NULL.
-   */
-  virtual void TearDown();
-
-  /**
-   * Accesses the display representing an Xlib connection.
-   *
-   * Accessible by subclasses and test cases relying on this fixture.
-   *
-   * @returns Pointer to a display or NULL.
-   */
-  ::Display* Display() const;
-
-  /** @cond Implementation */
-  struct Private;
-  std::auto_ptr<Private> d_;
-  /** @endcond Implementation */
- private:
-  /* Disable copy c'tor, assignment operator */
-  Test(const Test&);
-  Test& operator=(const Test&);
-};
-
-} // namespace testing
-} // namespace xorg
-
-#endif // XORG_GTEST_TEST_H_
+#warning "This header is deprecated. Include xorg-gtest-test.h instead"
+#include "xorg-gtest-test.h"
diff --git a/src/device.cpp b/src/device.cpp
index 89eb8ea..226d4e0 100644
--- a/src/device.cpp
+++ b/src/device.cpp
@@ -25,7 +25,7 @@
  *
  ******************************************************************************/
 
-#include "xorg/gtest/evemu/xorg-gtest_device.h"
+#include "xorg/gtest/evemu/xorg-gtest-device.h"
 
 #include <fcntl.h>
 
diff --git a/src/environment.cpp b/src/environment.cpp
index 60a5190..c29d4a8 100644
--- a/src/environment.cpp
+++ b/src/environment.cpp
@@ -25,8 +25,8 @@
  *
  ******************************************************************************/
 
-#include "xorg/gtest/xorg-gtest_environment.h"
-#include "xorg/gtest/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 c11f12f..e79b694 100644
--- a/src/process.cpp
+++ b/src/process.cpp
@@ -25,7 +25,7 @@
  *
  ******************************************************************************/
 
-#include "xorg/gtest/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 f016f06..e3e65e4 100644
--- a/src/test.cpp
+++ b/src/test.cpp
@@ -25,7 +25,7 @@
  *
  ******************************************************************************/
 
-#include "xorg/gtest/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 08927a0..22c9049 100644
--- a/src/xorg-gtest_main.cpp
+++ b/src/xorg-gtest_main.cpp
@@ -31,7 +31,7 @@
 
 #include <gtest/gtest.h>
 
-#include "xorg/gtest/xorg-gtest_environment.h"
+#include "xorg/gtest/xorg-gtest-environment.h"
 #include "defines.h"
 
 namespace {
-- 
1.7.10.2



More information about the xorg-devel mailing list