/usr/share/doc/xorg-gtest/html/xorg-gtest-environment-example_8cpp-example.html is in libxorg-gtest-doc 0.7.1-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.4"/>
<title>xorg-gtest: xorg-gtest-environment-example.cpp</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
$(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">xorg-gtest
 <span id="projectnumber">0.1</span>
</div>
<div id="projectbrief">Xorg testing extension to Google Test</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.4 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('xorg-gtest-environment-example_8cpp-example.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Pages</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="headertitle">
<div class="title">xorg-gtest-environment-example.cpp</div> </div>
</div><!--header-->
<div class="contents">
<p>This is an example for using the fixture <a class="el" href="classxorg_1_1testing_1_1_test.html" title="Google Test fixture providing an Xlib connection to an X11 server. ">xorg::testing::Test</a> for your own tests, using the <a class="el" href="classxorg_1_1testing_1_1_environment.html" title="xorg/gtest/xorg-gtest-environment.h ">xorg::testing::Environment</a> to start up a server.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.</p>
<p>The <a class="el" href="classxorg_1_1testing_1_1_environment.html" title="xorg/gtest/xorg-gtest-environment.h ">xorg::testing::Environment</a> starts up one server before the test execution, that server is alive during all tests until the end of the test suite. For options on controlling that server run this test with –help, the configuration path, display number can be controlled by the caller.</p>
<p>Note that the test environment (i.e. the X server instance) is shared between tests. If the tests are the only client connection, the server will trigger a regeneration when the test finishes with Test::TearDown(). If more than one client connection is active however, this regeneration will not happen and changes made by one test can affect outcomes on other tests.</p>
<p>This test is missing a main(), we pull that in from xorg-gtest-main.cpp</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include <xorg/gtest/xorg-gtest.h></span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#include <X11/extensions/XInput2.h></span></div>
<div class="line"><span class="preprocessor">#include <X11/Xatom.h></span></div>
<div class="line"></div>
<div class="line"><span class="keyword">using namespace </span>xorg::testing;</div>
<div class="line"></div>
<div class="line"><span class="comment">/* This must be a TEST_F to ensure we get the goodies from</span></div>
<div class="line"><span class="comment"> * ::xorg::testing::Test */</span></div>
<div class="line">TEST_F(<a name="_a0"></a><a class="code" href="classxorg_1_1testing_1_1_test.html" title="Google Test fixture providing an Xlib connection to an X11 server. ">Test</a>, DummyXorgServerTest) {</div>
<div class="line"></div>
<div class="line"> <span class="comment">/* Display() contains the display connection to the X server */</span></div>
<div class="line"> EXPECT_NE((Window)None, DefaultRootWindow(Display()));</div>
<div class="line"></div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="comment">/* Another test querying for input devices. */</span></div>
<div class="line">TEST_F(<a class="code" href="classxorg_1_1testing_1_1_test.html" title="Google Test fixture providing an Xlib connection to an X11 server. ">Test</a>, XIQueryVersion20) {</div>
<div class="line"> <span class="keywordtype">int</span> major = 2, minor = 0;</div>
<div class="line"></div>
<div class="line"> ASSERT_EQ(Success, XIQueryVersion(Display(), &major, &minor));</div>
<div class="line"> ASSERT_GE(major * 100 + minor, 200);</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="comment">/* Even though we queried for 2.0 above, we can query again for 2.2. Each</span></div>
<div class="line"><span class="comment"> * TEST_F has a new Display */</span></div>
<div class="line">TEST_F(<a class="code" href="classxorg_1_1testing_1_1_test.html" title="Google Test fixture providing an Xlib connection to an X11 server. ">Test</a>, XIQueryVersion22) {</div>
<div class="line"> <span class="keywordtype">int</span> major = 2, minor = 2;</div>
<div class="line"></div>
<div class="line"> ASSERT_EQ(Success, XIQueryVersion(Display(), &major, &minor));</div>
<div class="line"> ASSERT_EQ(major * 100 + minor, 202);</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="comment">/* The next two tests illustrates a potential test dependency.</span></div>
<div class="line"><span class="comment"> * Test.CreateWindowProperty creates a property on the root window. If our</span></div>
<div class="line"><span class="comment"> * connection is the only Display connection, the server will regenerate</span></div>
<div class="line"><span class="comment"> * after Test::TearDown and the property is removed becore</span></div>
<div class="line"><span class="comment"> * Test.CheckWindowProperty is called. If some other client holds the</span></div>
<div class="line"><span class="comment"> * connection open, the property stays alive.</span></div>
<div class="line"><span class="comment"> */</span></div>
<div class="line">TEST_F(<a class="code" href="classxorg_1_1testing_1_1_test.html" title="Google Test fixture providing an Xlib connection to an X11 server. ">Test</a>, CreateWindowProperty) {</div>
<div class="line"> Atom prop = XInternAtom(Display(), <span class="stringliteral">"xorg-gtest test atom"</span>, False);</div>
<div class="line"> ASSERT_NE((Atom)None, prop);</div>
<div class="line"></div>
<div class="line"> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> data = 1;</div>
<div class="line"> XChangeProperty(Display(), DefaultRootWindow(Display()), prop,</div>
<div class="line"> XA_INTEGER, 8, PropModeReplace, &data, 1);</div>
<div class="line"> XFlush(Display());</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line">TEST_F(<a class="code" href="classxorg_1_1testing_1_1_test.html" title="Google Test fixture providing an Xlib connection to an X11 server. ">Test</a>, CheckWindowProperty) {</div>
<div class="line"> Atom prop = XInternAtom(Display(), <span class="stringliteral">"xorg-gtest test atom"</span>, True);</div>
<div class="line"> ASSERT_EQ((Atom)None, prop) << <span class="stringliteral">"Property did not get removed, some client prevented regeneration"</span>;</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keyword">class </span><a name="_a1"></a><a class="code" href="class_sub_test.html" title="Example class for how to subclass tests. ">SubTest</a> : <span class="keyword">public</span> <a class="code" href="classxorg_1_1testing_1_1_test.html" title="Google Test fixture providing an Xlib connection to an X11 server. ">Test</a> {</div>
<div class="line"><span class="keyword">public</span>:</div>
<div class="line"> <span class="keyword">virtual</span> <span class="keywordtype">void</span> SetUp(<span class="keywordtype">void</span>) {</div>
<div class="line"> <a name="a2"></a><a class="code" href="classxorg_1_1testing_1_1_test.html#a97fad2005391c683facb80a937ae5b34" title="Tries to connect to an X server instance. ">Test::SetUp</a>();</div>
<div class="line"></div>
<div class="line"> <span class="comment">/* Create some atom that we can then use inside the test */</span></div>
<div class="line"> example_prop = XInternAtom(Display(), <span class="stringliteral">"xorg-gtest example atom"</span>, False);</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"><span class="keyword">protected</span>:</div>
<div class="line"> Atom example_prop;</div>
<div class="line">};</div>
<div class="line"></div>
<div class="line">TEST_F(<a class="code" href="class_sub_test.html" title="Example class for how to subclass tests. ">SubTest</a>, ExampleAtom) {</div>
<div class="line"> <span class="comment">/* We have access to SubTest's member public and protected variables here */</span></div>
<div class="line"> ASSERT_NE((Atom)None, example_prop);</div>
<div class="line">}</div>
</div><!-- fragment --> </div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Generated on Tue Jul 16 2013 08:55:12 for xorg-gtest by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.4 </li>
</ul>
</div>
</body>
</html>
|