Commit b0417d54 authored by Peter Hutterer's avatar Peter Hutterer
Browse files

xserver: store config, logfile, binary paths in the XServer object



And provide a SetOption call for the various commandline options that the
server may take.
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: default avatarChase Douglas <chase.douglas@canonical.com>
parent d5e07ba3
......@@ -55,6 +55,14 @@ class XServer : public xorg::testing::Process {
*/
void SetDisplayNumber(unsigned int display_number);
/**
* Set the path to the server binary to be started. Optional call, if
* not invoked the built-in default path is chosen.
*
* @param [in] path_to_server The path to the binary
*/
void SetServerPath(const std::string &path_to_server);
/**
* Get the display number from this server. If the server was not
* started yet, this function returns the display number the server will
......@@ -72,6 +80,17 @@ class XServer : public xorg::testing::Process {
*/
const std::string& GetDisplayString(void);
/**
* Set startup options for the server.
*
* For arguments that do not take/need a value, use the empty string as
* value.
*
* @param [in] key Commandline option
* @param [in] value Option value (if any)
*/
void SetOption(const std::string &key, const std::string &value);
/**
* Wait for a specific device to be added to the server.
*
......
......@@ -142,6 +142,8 @@ void xorg::testing::Environment::SetUp() {
}
d_->server.SetDisplayNumber(d_->display);
d_->server.SetOption("-logfile", d_->path_to_log_file);
d_->server.SetOption("-config", d_->path_to_conf);
d_->server.Start(d_->path_to_server, d_->path_to_server.c_str(),
display_string,
"-logverbose", "10",
......
......@@ -27,6 +27,7 @@
******************************************************************************/
#include "xorg/gtest/xorg-gtest-xserver.h"
#include "defines.h"
#include <sys/types.h>
#include <sys/wait.h>
......@@ -40,12 +41,23 @@
#include <cstring>
#include <stdexcept>
#include <vector>
#include <map>
#include <X11/extensions/XInput2.h>
struct xorg::testing::XServer::Private {
Private()
: display_number(DEFAULT_DISPLAY),
path_to_server(DEFAULT_XORG_SERVER) {
options["-config"] = DUMMY_CONF_PATH;
options["-logfile"] = DEFAULT_XORG_LOGFILE;
}
unsigned int display_number;
std::string display_string;
std::string path_to_server;
std::map<std::string, std::string> options;
};
xorg::testing::XServer::XServer() : d_(new Private) {
......@@ -69,6 +81,10 @@ const std::string& xorg::testing::XServer::GetDisplayString(void) {
return d_->display_string;
}
void xorg::testing::XServer::SetServerPath(const std::string &path_to_server) {
d_->path_to_server = path_to_server;
}
bool xorg::testing::XServer::WaitForEvent(::Display *display, time_t timeout)
{
fd_set fds;
......@@ -195,3 +211,7 @@ bool xorg::testing::XServer::WaitForDevice(::Display *display, const std::string
return false;
}
void xorg::testing::XServer::SetOption(const std::string &key, const std::string &value) {
d_->options[key] = value;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment