xorg-gtest  0.1
Xorg testing extension to Google Test
xorg::testing::Test Class Reference

#include <xorg/gtest/xorg-gtest-test.h>

Inheritance diagram for xorg::testing::Test:
ServerTest SubTest

Protected Member Functions

virtual void SetUp ()
 Tries to connect to an X server instance. More...
 
virtual void TearDown ()
 Closes the display. More...
 
::Display * Display () const
 Accesses the display representing an Xlib connection. More...
 
void SetDisplayString (const std::string &display)
 Set the display string used for XOpenDisplay() and thus affects Test::Display(). More...
 

Detailed Description

Google Test fixture providing an Xlib connection to an X11 server.

Sets up and tears down an XLib connection to an X11 server. Rely on Google Test's TEST_F macro to use this fixture for your own tests or subclass it and override the SetUp and TearDown methods.

Remarks
The display port is read from the environment variable DISPLAY.
Examples
xorg-gtest-environment-example.cpp, and xorg-gtest-example.cpp.

Member Function Documentation

◆ Display()

::Display* xorg::testing::Test::Display ( ) const
protected

Accesses the display representing an Xlib connection.

Accessible by subclasses and test cases relying on this fixture.

Returns
Pointer to a display or NULL.

◆ SetDisplayString()

void xorg::testing::Test::SetDisplayString ( const std::string &  display)
protected

Set the display string used for XOpenDisplay() and thus affects Test::Display().

This function must be called before xorg::testing::Test::SetUp() to have any effect.

Parameters
displayThe string representing the display connection, or an empty string for NULL
Examples
xorg-gtest-example.cpp.

◆ SetUp()

virtual void xorg::testing::Test::SetUp ( )
protectedvirtual

Tries to connect to an X server instance.

Fails if no X server is running. Updates the display object. Reimplemented from ::testing::Test. See Google Test documentation for details.

Postcondition
Subsequent calls to Display() return a valid pointer or NULL if an error occured.
Exceptions
std::runtime_errorif no X server is running.

Reimplemented in SubTest, and ServerTest.

Examples
xorg-gtest-environment-example.cpp, and xorg-gtest-example.cpp.

◆ TearDown()

virtual void xorg::testing::Test::TearDown ( )
protectedvirtual

Closes the display.

Reimplemented from ::testing::Test. See Google Test documentation for details.

Postcondition
Subsequent calls to Display() return NULL.

Reimplemented in ServerTest.


The documentation for this class was generated from the following file: