From fa46480c35d00a78b7d00f8a4ebc5b5d188b3030 Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Sat, 22 Aug 2020 11:46:25 +0100 Subject: [PATCH] Respect DISPLAY environment variable in XWindows tests XWindowsScreenTests was failing under Gentoo's package manager. I have also addressed this in XWindowsScreenSaverTests, which is currently unused. --- src/test/integtests/platform/XWindowsScreenSaverTests.cpp | 8 +++++++- src/test/integtests/platform/XWindowsScreenTests.cpp | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/test/integtests/platform/XWindowsScreenSaverTests.cpp b/src/test/integtests/platform/XWindowsScreenSaverTests.cpp index c6a2710c..a3af21dd 100644 --- a/src/test/integtests/platform/XWindowsScreenSaverTests.cpp +++ b/src/test/integtests/platform/XWindowsScreenSaverTests.cpp @@ -23,6 +23,7 @@ #include "platform/XWindowsScreenSaver.h" #include "test/global/gtest.h" +#include #include using ::testing::_; @@ -30,7 +31,12 @@ using ::testing::_; // TODO: not working on build machine for some reason TEST(CXWindowsScreenSaverTests, activate_defaultScreen_todo) { - Display* display = XOpenDisplay(":0.0"); + const char* displayName = std::getenv("DISPLAY"); + if (displayName == NULL) { + displayName = ":0.0"; + } + + Display* display = XOpenDisplay(displayName); Window window = DefaultRootWindow(display); MockEventQueue eventQueue; EXPECT_CALL(eventQueue, removeHandler(_, _)).Times(1); diff --git a/src/test/integtests/platform/XWindowsScreenTests.cpp b/src/test/integtests/platform/XWindowsScreenTests.cpp index d8f75e15..53f113e7 100644 --- a/src/test/integtests/platform/XWindowsScreenTests.cpp +++ b/src/test/integtests/platform/XWindowsScreenTests.cpp @@ -20,16 +20,22 @@ #include "platform/XWindowsScreen.h" #include "test/global/gtest.h" +#include using ::testing::_; TEST(CXWindowsScreenTests, fakeMouseMove_nonPrimary_getCursorPosValuesCorrect) { + const char* displayName = std::getenv("DISPLAY"); + if (displayName == NULL) { + displayName = ":0.0"; + } + MockEventQueue eventQueue; EXPECT_CALL(eventQueue, adoptHandler(_, _, _)).Times(2); EXPECT_CALL(eventQueue, adoptBuffer(_)).Times(2); EXPECT_CALL(eventQueue, removeHandler(_, _)).Times(2); - XWindowsScreen screen(new XWindowsImpl(), ":0.0", false, false, 0, &eventQueue); + XWindowsScreen screen(new XWindowsImpl(), displayName, false, false, 0, &eventQueue); screen.fakeMouseMove(10, 20);