Commit b6dcdde9 authored by Peter Hutterer's avatar Peter Hutterer Committed by Chase Douglas
Browse files

Rename headers to use dashes only



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's avatarPeter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: default avatarChase Douglas <chase.douglas@canonical.com>
Signed-off-by: default avatarChase Douglas <chase.douglas@canonical.com>
parent a008b754
......@@ -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)
/*******************************************************************************
*
* 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_
/*******************************************************************************
*
* 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"
/*******************************************************************************
*
* 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
/*******************************************************************************
*
* 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
/*******************************************************************************
*
* 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.
*