Don't rely on the environment alone, take the display string if it's been set.
Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> --- include/xorg/gtest/xorg-gtest-test.h | 7 +++++++ src/test.cpp | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/xorg/gtest/xorg-gtest-test.h b/include/xorg/gtest/xorg-gtest-test.h index 3b78a17..3338c80 100644 --- a/include/xorg/gtest/xorg-gtest-test.h +++ b/include/xorg/gtest/xorg-gtest-test.h @@ -88,6 +88,13 @@ class Test : public ::testing::Test { */ ::Display* Display() const; + /** + * Set the display string used for XOpenDisplay() + * + * @param display The string representing the display connection, or NULL + */ + void SetDisplayString(const char *display); + /** @cond Implementation */ struct Private; std::auto_ptr<Private> d_; diff --git a/src/test.cpp b/src/test.cpp index e3e65e4..499915b 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -33,16 +33,18 @@ struct xorg::testing::Test::Private { ::Display* display; + const char *display_string; }; xorg::testing::Test::Test() : d_(new Private) { d_->display = NULL; + d_->display_string = NULL; } xorg::testing::Test::~Test() {} void xorg::testing::Test::SetUp() { - d_->display = XOpenDisplay(NULL); + d_->display = XOpenDisplay(d_->display_string); if (!d_->display) throw std::runtime_error("Failed to open connection to display"); } @@ -56,3 +58,7 @@ void xorg::testing::Test::TearDown() { ::Display* xorg::testing::Test::Display() const { return d_->display; } + +void xorg::testing::Test::SetDisplayString(const char *display) { + d_->display_string = display; +} -- 1.7.10.4 _______________________________________________ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel