These are examples for using xorg-gtest in tests and test fixtures.Please make sure that you have the X.org dummy display driver installed on your system and that you execute the test with root privileges.
Each of these tests starts a new server.
#include <xorg/gtest/xorg-gtest.h>
#include <sstream>
#include <X11/extensions/XInput2.h>
#include <X11/Xatom.h>
server.
SetOption(
"-logfile", LOGFILE_DIR
"/xserver-startserver.log");
server.
SetOption(
"-config", DUMMY_CONF_PATH);
}
server.
SetOption(
"-logfile", LOGFILE_DIR
"/xserver-display-connection.log");
server.
SetOption(
"-config", DUMMY_CONF_PATH);
ASSERT_TRUE(dpy != NULL);
}
public:
virtual void SetUp(void) {
const ::testing::TestInfo* const test_info =
::testing::UnitTest::GetInstance()->current_test_info();
std::stringstream log;
log << LOGFILE_DIR "/xserver-";
log << test_info->test_case_name() << "." << test_info->name();
log << ".log";
server.
SetOption(
"-config", DUMMY_CONF_PATH);
}
virtual void TearDown(void) {
}
protected:
};
ASSERT_GT(DisplayWidth(Display(), 0), 0);
}
ASSERT_GT(DisplayHeight(Display(), 0), 0);
}
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}