xorg-gtest
0.1
Xorg testing extension to Google Test
|
Class representing the X server process. More...
#include <xorg/gtest/xorg-gtest-xserver.h>
Public Member Functions | |
virtual void | Start (const std::string &program="") |
Start a new server. More... | |
virtual bool | Terminate (unsigned int timeout=2000) |
Terminates this server process. More... | |
virtual bool | Kill (unsigned int timeout=2000) |
Kills the server. More... | |
void | RemoveLogFile (bool force=false) |
Remove the log file used by this server. More... | |
_X_DEPRECATED void | WaitForConnections (void) |
Waits until this server is ready to take connections. More... | |
void | SetDisplayNumber (unsigned int display_number) |
Set the display number for this server. More... | |
void | SetServerPath (const std::string &path_to_server) |
Set the path to the server binary to be started. More... | |
unsigned int | GetDisplayNumber (void) |
Get the display number from this server. More... | |
const std::string & | GetDisplayString (void) |
Get the display string that may be used for XOpenDisplay to this server. More... | |
const std::string & | GetVersion () |
Get the X server version as printed into the log file, usually in the form a.b.c[.d], with d being the optional part for release candidates. More... | |
const std::string & | GetLogFilePath () |
Get the server's log file path. More... | |
const std::string & | GetConfigPath () |
Get the server's config file path. More... | |
void | SetOption (const std::string &key, const std::string &value="") |
Set startup options for the server. More... | |
void | RemoveOption (const std::string &option) |
Remove a previously set option. More... | |
![]() | |
Process () | |
Creates a child-process that is in a terminated state. More... | |
pid_t | Fork () |
Fork manually. More... | |
void | Start (const std::string &program, const std::vector< std::string > &args) |
Starts a program as a child process. More... | |
void | Start (const std::string &program, va_list *args) |
Starts a program as a child process. More... | |
void | Start (const std::string &program,...) _X_SENTINEL(0) |
Starts a program as a child process. More... | |
pid_t | Pid () const |
Accesses the pid of the child process. More... | |
enum Process::State | GetState () |
Return the state of the process. More... | |
Static Public Member Functions | |
static bool | WaitForDevice (::Display *display, const std::string &name, time_t timeout=1000) |
Wait for a specific device to be added to the server. More... | |
static bool | WaitForEvent (::Display *display, time_t timeout=1000) |
Wait for an event on the X connection. More... | |
static bool | WaitForEventOfType (::Display *display, int type, int extension=-1, int evtype=-1, time_t timeout=1000) |
Wait for an event of a specific type on the X connection. More... | |
static void | RegisterXIOErrorHandler () |
Install a default XIOErrorHandler. More... | |
static void | RegisterXErrorHandler () |
Install a default XErrorHandler. More... | |
![]() | |
static void | SetEnv (const std::string &name, const std::string &value, bool overwrite) |
Helper function to adjust the environment of the current process. More... | |
static std::string | GetEnv (const std::string &name, bool *exists=NULL) |
Helper function to query the environment of the current process. More... | |
Additional Inherited Members | |
![]() | |
enum | State { ERROR, NONE, RUNNING, FINISHED_SUCCESS, FINISHED_FAILURE, TERMINATED } |
Describes the state of a process as seen by this library. More... | |
Class representing the X server process.
Once a XServer is started, a default XIOErrorHandler is installed and subsequent IO errors on the display connection will throw an XIOError.
const std::string& xorg::testing::XServer::GetConfigPath | ( | ) |
Get the server's config file path.
If this path is empty, the server will use it's built-in config file path.
unsigned int xorg::testing::XServer::GetDisplayNumber | ( | void | ) |
Get the display number from this server.
If the server was not started yet, this function returns the display number the server will be started on.
const std::string& xorg::testing::XServer::GetDisplayString | ( | void | ) |
Get the display string that may be used for XOpenDisplay to this server.
This string is effectively :display_number.
const std::string& xorg::testing::XServer::GetLogFilePath | ( | ) |
Get the server's log file path.
If this path is empty, the server will use it's built-in log file path.
const std::string& xorg::testing::XServer::GetVersion | ( | ) |
Get the X server version as printed into the log file, usually in the form a.b.c[.d], with d being the optional part for release candidates.
|
virtual |
Kills the server.
With a vengeance.
[in] | timeout | The timeout in millis to wait for the process to terminate. A timeout of 0 implies not to wait but return immediately. |
Reimplemented from xorg::testing::Process.
|
static |
Install a default XErrorHandler.
That error handler will cause a test failure if called.
This function is called automatically by XServer::Start(). Usually, you will not need to call this function unless your test does not instantiate and Start() an XServer object.
This function will only install a new error handler if the currently installed XErrorHandler is not the default handler used by Xlib.
|
static |
Install a default XIOErrorHandler.
That error handler will throw an xorg::testing::XIOError when encountered.
This function is called automatically by XServer::Start(). Usually, you will not need to call this function unless your test does not instantiate and Start() an XServer object.
This function will only install a new error handler if the currently installed XIOErrorHandler is not the default handler used by Xlib.
void xorg::testing::XServer::RemoveLogFile | ( | bool | force = false | ) |
Remove the log file used by this server.
By default, this function only removes the log file if the server was terminated or finished with an exit code of 0.
If force is true, the log file is removed regardless of the state of the server.
force | Force removal of the log file |
void xorg::testing::XServer::RemoveOption | ( | const std::string & | option | ) |
Remove a previously set option.
If an option was set through SetOption(), remove the option again. If the specified option has never been set, do nothing.
[in] | option | Commandline option to remove |
void xorg::testing::XServer::SetDisplayNumber | ( | unsigned int | display_number | ) |
Set the display number for this server.
This number must be set before the server is started to have any effect. If unset, the default display number is used.
[in] | display_number | The display number the server runs on |
void xorg::testing::XServer::SetOption | ( | const std::string & | key, |
const std::string & | value = "" |
||
) |
Set startup options for the server.
For arguments that do not take/need a value, use the empty string as value.
[in] | key | Commandline option |
[in] | value | Option value (if any) |
void xorg::testing::XServer::SetServerPath | ( | const std::string & | path_to_server | ) |
Set the path to the server binary to be started.
Optional call, if not invoked the built-in default path is chosen.
[in] | path_to_server | The path to the binary |
|
virtual |
Start a new server.
If no binary is given, the server started is the default compiled-in server binary.
[in] | program | Path to the XServer binary |
|
virtual |
Terminates this server process.
Will signal the server to terminate multiple times before giving up.
[in] | timeout | The timeout in millis to wait for the process to terminate. A timeout of 0 implies not to wait but return immediately. |
Reimplemented from xorg::testing::Process.
_X_DEPRECATED void xorg::testing::XServer::WaitForConnections | ( | void | ) |
Waits until this server is ready to take connections.
|
static |
Wait for a specific device to be added to the server.
[in] | display | The X display connection |
[in] | name | The name of the device to wait for |
[in] | timeout | The timeout in milliseconds |
|
static |
Wait for an event on the X connection.
[in] | display | The X display connection |
[in] | timeout | The timeout in milliseconds |
|
static |
Wait for an event of a specific type on the X connection.
All events preceding the matching event are discarded. If no event was found before the timeout expires, all events in the queue will have been discarded.
[in] | display | The X display connection |
[in] | type | The X core protocol event type |
[in] | extension | The X extension opcode of a generic event, or -1 for any generic event |
[in] | evtype | The X extension event type of a generic event, or -1 for any event of the given extension |
[in] | timeout | The timeout in milliseconds |