/usr/share/doc/xorg-gtest/html/xorg-gtest-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 192 193 194 195 196 197 198 | <!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-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-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-example.cpp</div> </div>
</div><!--header-->
<div class="contents">
<p>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.</p>
<p>Each of these tests starts a new server.</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 <sstream></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">TEST(<a name="_a0"></a><a class="code" href="classxorg_1_1testing_1_1_x_server.html" title="Class representing the X server process. ">XServer</a>, StartServer) {</div>
<div class="line"> <a class="code" href="classxorg_1_1testing_1_1_x_server.html" title="Class representing the X server process. ">XServer</a> server;</div>
<div class="line"> server.<a name="a1"></a><a class="code" href="classxorg_1_1testing_1_1_x_server.html#acd9a21aa813bda0528d121a3d9451db3" title="Set startup options for the server. ">SetOption</a>(<span class="stringliteral">"-logfile"</span>, LOGFILE_DIR <span class="stringliteral">"/xserver-startserver.log"</span>);</div>
<div class="line"> server.<a class="code" href="classxorg_1_1testing_1_1_x_server.html#acd9a21aa813bda0528d121a3d9451db3" title="Set startup options for the server. ">SetOption</a>(<span class="stringliteral">"-config"</span>, DUMMY_CONF_PATH);</div>
<div class="line"> server.<a name="a2"></a><a class="code" href="classxorg_1_1testing_1_1_x_server.html#af88d34f234f0e5b203e50c607f8a294d" title="Start a new server. ">Start</a>();</div>
<div class="line"></div>
<div class="line"> ASSERT_EQ(server.<a name="a3"></a><a class="code" href="classxorg_1_1testing_1_1_process.html#ad9a2be6fe4da7403927de57eb25558d6" title="Return the state of the process. ">GetState</a>(), <a name="a4"></a><a class="code" href="classxorg_1_1testing_1_1_process.html#a8db18f3e5adcf4e83abba0dd0924790da0155e469d65050e7f8e10ee97f6a293c" title="The process has been started. ">Process::RUNNING</a>);</div>
<div class="line"> ASSERT_TRUE(server.<a name="a5"></a><a class="code" href="classxorg_1_1testing_1_1_x_server.html#a303107754d55d4e73bdaf8e67443479b" title="Terminates this server process. ">Terminate</a>());</div>
<div class="line"> ASSERT_EQ(server.<a class="code" href="classxorg_1_1testing_1_1_process.html#ad9a2be6fe4da7403927de57eb25558d6" title="Return the state of the process. ">GetState</a>(), <a name="a6"></a><a class="code" href="classxorg_1_1testing_1_1_process.html#a8db18f3e5adcf4e83abba0dd0924790daf8a23d1a219b5a5a53ab058c2ed18408" title="The process finished with an exit code of 0. ">Process::FINISHED_SUCCESS</a>);</div>
<div class="line"></div>
<div class="line"> <span class="comment">/* If we get here, we were successful,so remove the log file */</span></div>
<div class="line"> server.<a name="a7"></a><a class="code" href="classxorg_1_1testing_1_1_x_server.html#a534814b999a635a7466b433b1a3ae698" title="Remove the log file used by this server. ">RemoveLogFile</a>();</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line">TEST(<a class="code" href="classxorg_1_1testing_1_1_x_server.html" title="Class representing the X server process. ">XServer</a>, DisplayConnection) {</div>
<div class="line"> <a class="code" href="classxorg_1_1testing_1_1_x_server.html" title="Class representing the X server process. ">XServer</a> server;</div>
<div class="line"> server.<a class="code" href="classxorg_1_1testing_1_1_x_server.html#acd9a21aa813bda0528d121a3d9451db3" title="Set startup options for the server. ">SetOption</a>(<span class="stringliteral">"-logfile"</span>, LOGFILE_DIR <span class="stringliteral">"/xserver-display-connection.log"</span>);</div>
<div class="line"> server.<a class="code" href="classxorg_1_1testing_1_1_x_server.html#acd9a21aa813bda0528d121a3d9451db3" title="Set startup options for the server. ">SetOption</a>(<span class="stringliteral">"-config"</span>, DUMMY_CONF_PATH);</div>
<div class="line"> server.<a class="code" href="classxorg_1_1testing_1_1_x_server.html#af88d34f234f0e5b203e50c607f8a294d" title="Start a new server. ">Start</a>();</div>
<div class="line"></div>
<div class="line"> Display *dpy = XOpenDisplay(server.<a name="a8"></a><a class="code" href="classxorg_1_1testing_1_1_x_server.html#a84d43840f727bcdb82b8897a340ef97f" title="Get the display string that may be used for XOpenDisplay to this server. ">GetDisplayString</a>().c_str());</div>
<div class="line"> ASSERT_TRUE(dpy != NULL);</div>
<div class="line"></div>
<div class="line"> <span class="comment">/* calling Terminate isn't necessary as the destructor will do it for us,</span></div>
<div class="line"><span class="comment"> but we do want the log file removed. That only works on terminated</span></div>
<div class="line"><span class="comment"> servers. */</span></div>
<div class="line"> server.<a class="code" href="classxorg_1_1testing_1_1_x_server.html#a303107754d55d4e73bdaf8e67443479b" title="Terminates this server process. ">Terminate</a>();</div>
<div class="line"> server.<a class="code" href="classxorg_1_1testing_1_1_x_server.html#a534814b999a635a7466b433b1a3ae698" title="Remove the log file used by this server. ">RemoveLogFile</a>();</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keyword">class </span><a name="_a9"></a><a class="code" href="class_server_test.html" title="Example for a test fixture that starts a server per test. ">ServerTest</a> : <span class="keyword">public</span> <a name="_a10"></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> {</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"> const ::testing::TestInfo* <span class="keyword">const</span> test_info =</div>
<div class="line"> ::testing::UnitTest::GetInstance()->current_test_info();</div>
<div class="line"></div>
<div class="line"> <span class="comment">/* Use a log file based on the test name. NOTE: test names for</span></div>
<div class="line"><span class="comment"> parameterized tests end in /0, /1, etc. */</span></div>
<div class="line"> std::stringstream log;</div>
<div class="line"> log << LOGFILE_DIR <span class="stringliteral">"/xserver-"</span>;</div>
<div class="line"> log << test_info->test_case_name() << <span class="stringliteral">"."</span> << test_info->name();</div>
<div class="line"> log << <span class="stringliteral">".log"</span>;</div>
<div class="line"></div>
<div class="line"> server.<a class="code" href="classxorg_1_1testing_1_1_x_server.html#acd9a21aa813bda0528d121a3d9451db3" title="Set startup options for the server. ">SetOption</a>(<span class="stringliteral">"-logfile"</span>, log.str());</div>
<div class="line"> server.<a class="code" href="classxorg_1_1testing_1_1_x_server.html#acd9a21aa813bda0528d121a3d9451db3" title="Set startup options for the server. ">SetOption</a>(<span class="stringliteral">"-config"</span>, DUMMY_CONF_PATH);</div>
<div class="line"> server.<a class="code" href="classxorg_1_1testing_1_1_x_server.html#af88d34f234f0e5b203e50c607f8a294d" title="Start a new server. ">Start</a>();</div>
<div class="line"></div>
<div class="line"> <span class="comment">/* set up Display() */</span></div>
<div class="line"> <a name="a11"></a><a class="code" href="classxorg_1_1testing_1_1_test.html#a8bcc70589021f721f715696314c03dcb" title="Set the display string used for XOpenDisplay() and thus affects Test::Display(). ">Test::SetDisplayString</a>(server.<a class="code" href="classxorg_1_1testing_1_1_x_server.html#a84d43840f727bcdb82b8897a340ef97f" title="Get the display string that may be used for XOpenDisplay to this server. ">GetDisplayString</a>());</div>
<div class="line"> ASSERT_NO_FATAL_FAILURE(<a name="a12"></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"></div>
<div class="line"> <span class="keyword">virtual</span> <span class="keywordtype">void</span> TearDown(<span class="keywordtype">void</span>) {</div>
<div class="line"> ASSERT_TRUE(server.<a class="code" href="classxorg_1_1testing_1_1_x_server.html#a303107754d55d4e73bdaf8e67443479b" title="Terminates this server process. ">Terminate</a>());</div>
<div class="line"> server.<a class="code" href="classxorg_1_1testing_1_1_x_server.html#a534814b999a635a7466b433b1a3ae698" title="Remove the log file used by this server. ">RemoveLogFile</a>();</div>
<div class="line"> }</div>
<div class="line"><span class="keyword">protected</span>:</div>
<div class="line"> <a class="code" href="classxorg_1_1testing_1_1_x_server.html" title="Class representing the X server process. ">XServer</a> server;</div>
<div class="line">};</div>
<div class="line"></div>
<div class="line">TEST_F(<a class="code" href="class_server_test.html" title="Example for a test fixture that starts a server per test. ">ServerTest</a>, DisplayWidth) {</div>
<div class="line"> ASSERT_GT(DisplayWidth(Display(), 0), 0);</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line">TEST_F(<a class="code" href="class_server_test.html" title="Example for a test fixture that starts a server per test. ">ServerTest</a>, DisplayHeight) {</div>
<div class="line"> ASSERT_GT(DisplayHeight(Display(), 0), 0);</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv) {</div>
<div class="line"> ::testing::InitGoogleTest(&argc, argv);</div>
<div class="line"> <span class="keywordflow">return</span> RUN_ALL_TESTS();</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>
|