1 2<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 3<html><head><title>Python: package telemetry.testing.fakes</title> 4<meta charset="utf-8"> 5</head><body bgcolor="#f0f0f8"> 6 7<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> 8<tr bgcolor="#7799ee"> 9<td valign=bottom> <br> 10<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="telemetry.html"><font color="#ffffff">telemetry</font></a>.<a href="telemetry.testing.html"><font color="#ffffff">testing</font></a>.fakes</strong></big></big></font></td 11><td align=right valign=bottom 12><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="../telemetry/testing/fakes/__init__.py">telemetry/testing/fakes/__init__.py</a></font></td></tr></table> 13 <p><tt>Provides fakes for several of Telemetry's internal objects.<br> 14 <br> 15These allow code like story_runner and Benchmark to be run and tested<br> 16without compiling or starting a browser. Class names prepended with an<br> 17underscore are intended to be implementation details, and should not<br> 18be subclassed; however, some, like _FakeBrowser, have public APIs that<br> 19may need to be called in tests.</tt></p> 20<p> 21<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 22<tr bgcolor="#aa55cc"> 23<td colspan=3 valign=bottom> <br> 24<font color="#ffffff" face="helvetica, arial"><big><strong>Package Contents</strong></big></font></td></tr> 25 26<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td> 27<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p> 28<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 29<tr bgcolor="#ee77aa"> 30<td colspan=3 valign=bottom> <br> 31<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> 32 33<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td> 34<td width="100%"><dl> 35<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a> 36</font></dt><dd> 37<dl> 38<dt><font face="helvetica, arial"><a href="telemetry.testing.fakes.html#FakeHTTPServer">FakeHTTPServer</a> 39</font></dt><dt><font face="helvetica, arial"><a href="telemetry.testing.fakes.html#FakeInspectorWebsocket">FakeInspectorWebsocket</a> 40</font></dt><dt><font face="helvetica, arial"><a href="telemetry.testing.fakes.html#FakePlatform">FakePlatform</a> 41</font></dt><dd> 42<dl> 43<dt><font face="helvetica, arial"><a href="telemetry.testing.fakes.html#FakeLinuxPlatform">FakeLinuxPlatform</a> 44</font></dt></dl> 45</dd> 46<dt><font face="helvetica, arial"><a href="telemetry.testing.fakes.html#FakePossibleBrowser">FakePossibleBrowser</a> 47</font></dt></dl> 48</dd> 49<dt><font face="helvetica, arial"><a href="telemetry.internal.platform.system_info.html#SystemInfo">telemetry.internal.platform.system_info.SystemInfo</a>(<a href="__builtin__.html#object">__builtin__.object</a>) 50</font></dt><dd> 51<dl> 52<dt><font face="helvetica, arial"><a href="telemetry.testing.fakes.html#FakeSystemInfo">FakeSystemInfo</a> 53</font></dt></dl> 54</dd> 55<dt><font face="helvetica, arial"><a href="telemetry.page.shared_page_state.html#SharedPageState">telemetry.page.shared_page_state.SharedPageState</a>(<a href="telemetry.story.shared_state.html#SharedState">telemetry.story.shared_state.SharedState</a>) 56</font></dt><dd> 57<dl> 58<dt><font face="helvetica, arial"><a href="telemetry.testing.fakes.html#FakeSharedPageState">FakeSharedPageState</a> 59</font></dt></dl> 60</dd> 61</dl> 62 <p> 63<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 64<tr bgcolor="#ffc8d8"> 65<td colspan=3 valign=bottom> <br> 66<font color="#000000" face="helvetica, arial"><a name="FakeHTTPServer">class <strong>FakeHTTPServer</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> 67 68<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> 69<td width="100%">Methods defined here:<br> 70<dl><dt><a name="FakeHTTPServer-UrlOf"><strong>UrlOf</strong></a>(self, url)</dt></dl> 71 72<hr> 73Data descriptors defined here:<br> 74<dl><dt><strong>__dict__</strong></dt> 75<dd><tt>dictionary for instance variables (if defined)</tt></dd> 76</dl> 77<dl><dt><strong>__weakref__</strong></dt> 78<dd><tt>list of weak references to the object (if defined)</tt></dd> 79</dl> 80</td></tr></table> <p> 81<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 82<tr bgcolor="#ffc8d8"> 83<td colspan=3 valign=bottom> <br> 84<font color="#000000" face="helvetica, arial"><a name="FakeInspectorWebsocket">class <strong>FakeInspectorWebsocket</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> 85 86<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> 87<td width="100%">Methods defined here:<br> 88<dl><dt><a name="FakeInspectorWebsocket-AddAsyncResponse"><strong>AddAsyncResponse</strong></a>(self, method, result, time)</dt></dl> 89 90<dl><dt><a name="FakeInspectorWebsocket-AddEvent"><strong>AddEvent</strong></a>(self, method, params, time)</dt></dl> 91 92<dl><dt><a name="FakeInspectorWebsocket-AddResponseHandler"><strong>AddResponseHandler</strong></a>(self, method, handler)</dt></dl> 93 94<dl><dt><a name="FakeInspectorWebsocket-AsyncRequest"><strong>AsyncRequest</strong></a>(self, request, callback)</dt></dl> 95 96<dl><dt><a name="FakeInspectorWebsocket-Connect"><strong>Connect</strong></a>(self, _)</dt></dl> 97 98<dl><dt><a name="FakeInspectorWebsocket-DispatchNotifications"><strong>DispatchNotifications</strong></a>(self, timeout)</dt></dl> 99 100<dl><dt><a name="FakeInspectorWebsocket-RegisterDomain"><strong>RegisterDomain</strong></a>(self, _, handler)</dt></dl> 101 102<dl><dt><a name="FakeInspectorWebsocket-SendAndIgnoreResponse"><strong>SendAndIgnoreResponse</strong></a>(self, request)</dt></dl> 103 104<dl><dt><a name="FakeInspectorWebsocket-SyncRequest"><strong>SyncRequest</strong></a>(self, request, *_args, **_kwargs)</dt></dl> 105 106<dl><dt><a name="FakeInspectorWebsocket-__init__"><strong>__init__</strong></a>(self, mock_timer)</dt></dl> 107 108<hr> 109Data descriptors defined here:<br> 110<dl><dt><strong>__dict__</strong></dt> 111<dd><tt>dictionary for instance variables (if defined)</tt></dd> 112</dl> 113<dl><dt><strong>__weakref__</strong></dt> 114<dd><tt>list of weak references to the object (if defined)</tt></dd> 115</dl> 116</td></tr></table> <p> 117<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 118<tr bgcolor="#ffc8d8"> 119<td colspan=3 valign=bottom> <br> 120<font color="#000000" face="helvetica, arial"><a name="FakeLinuxPlatform">class <strong>FakeLinuxPlatform</strong></a>(<a href="telemetry.testing.fakes.html#FakePlatform">FakePlatform</a>)</font></td></tr> 121 122<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> 123<td width="100%"><dl><dt>Method resolution order:</dt> 124<dd><a href="telemetry.testing.fakes.html#FakeLinuxPlatform">FakeLinuxPlatform</a></dd> 125<dd><a href="telemetry.testing.fakes.html#FakePlatform">FakePlatform</a></dd> 126<dd><a href="__builtin__.html#object">__builtin__.object</a></dd> 127</dl> 128<hr> 129Methods defined here:<br> 130<dl><dt><a name="FakeLinuxPlatform-CanTakeScreenshot"><strong>CanTakeScreenshot</strong></a>(self)</dt></dl> 131 132<dl><dt><a name="FakeLinuxPlatform-GetArchName"><strong>GetArchName</strong></a>(self)</dt></dl> 133 134<dl><dt><a name="FakeLinuxPlatform-GetDeviceTypeName"><strong>GetDeviceTypeName</strong></a>(self)</dt></dl> 135 136<dl><dt><a name="FakeLinuxPlatform-GetOSName"><strong>GetOSName</strong></a>(self)</dt></dl> 137 138<dl><dt><a name="FakeLinuxPlatform-GetOSVersionName"><strong>GetOSVersionName</strong></a>(self)</dt></dl> 139 140<dl><dt><a name="FakeLinuxPlatform-SetHTTPServerDirectories"><strong>SetHTTPServerDirectories</strong></a>(self, paths)</dt></dl> 141 142<dl><dt><a name="FakeLinuxPlatform-TakeScreenshot"><strong>TakeScreenshot</strong></a>(self, file_path)</dt></dl> 143 144<dl><dt><a name="FakeLinuxPlatform-__init__"><strong>__init__</strong></a>(self)</dt></dl> 145 146<hr> 147Data descriptors defined here:<br> 148<dl><dt><strong>is_host_platform</strong></dt> 149</dl> 150<hr> 151Methods inherited from <a href="telemetry.testing.fakes.html#FakePlatform">FakePlatform</a>:<br> 152<dl><dt><a name="FakeLinuxPlatform-CanMonitorThermalThrottling"><strong>CanMonitorThermalThrottling</strong></a>(self)</dt></dl> 153 154<dl><dt><a name="FakeLinuxPlatform-HasBeenThermallyThrottled"><strong>HasBeenThermallyThrottled</strong></a>(self)</dt></dl> 155 156<dl><dt><a name="FakeLinuxPlatform-IsThermallyThrottled"><strong>IsThermallyThrottled</strong></a>(self)</dt></dl> 157 158<dl><dt><a name="FakeLinuxPlatform-StopAllLocalServers"><strong>StopAllLocalServers</strong></a>(self)</dt></dl> 159 160<hr> 161Data descriptors inherited from <a href="telemetry.testing.fakes.html#FakePlatform">FakePlatform</a>:<br> 162<dl><dt><strong>__dict__</strong></dt> 163<dd><tt>dictionary for instance variables (if defined)</tt></dd> 164</dl> 165<dl><dt><strong>__weakref__</strong></dt> 166<dd><tt>list of weak references to the object (if defined)</tt></dd> 167</dl> 168<dl><dt><strong>network_controller</strong></dt> 169</dl> 170<dl><dt><strong>tracing_controller</strong></dt> 171</dl> 172</td></tr></table> <p> 173<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 174<tr bgcolor="#ffc8d8"> 175<td colspan=3 valign=bottom> <br> 176<font color="#000000" face="helvetica, arial"><a name="FakePlatform">class <strong>FakePlatform</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> 177 178<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> 179<td width="100%">Methods defined here:<br> 180<dl><dt><a name="FakePlatform-CanMonitorThermalThrottling"><strong>CanMonitorThermalThrottling</strong></a>(self)</dt></dl> 181 182<dl><dt><a name="FakePlatform-GetArchName"><strong>GetArchName</strong></a>(self)</dt></dl> 183 184<dl><dt><a name="FakePlatform-GetDeviceTypeName"><strong>GetDeviceTypeName</strong></a>(self)</dt></dl> 185 186<dl><dt><a name="FakePlatform-GetOSName"><strong>GetOSName</strong></a>(self)</dt></dl> 187 188<dl><dt><a name="FakePlatform-GetOSVersionName"><strong>GetOSVersionName</strong></a>(self)</dt></dl> 189 190<dl><dt><a name="FakePlatform-HasBeenThermallyThrottled"><strong>HasBeenThermallyThrottled</strong></a>(self)</dt></dl> 191 192<dl><dt><a name="FakePlatform-IsThermallyThrottled"><strong>IsThermallyThrottled</strong></a>(self)</dt></dl> 193 194<dl><dt><a name="FakePlatform-StopAllLocalServers"><strong>StopAllLocalServers</strong></a>(self)</dt></dl> 195 196<hr> 197Data descriptors defined here:<br> 198<dl><dt><strong>__dict__</strong></dt> 199<dd><tt>dictionary for instance variables (if defined)</tt></dd> 200</dl> 201<dl><dt><strong>__weakref__</strong></dt> 202<dd><tt>list of weak references to the object (if defined)</tt></dd> 203</dl> 204<dl><dt><strong>is_host_platform</strong></dt> 205</dl> 206<dl><dt><strong>network_controller</strong></dt> 207</dl> 208<dl><dt><strong>tracing_controller</strong></dt> 209</dl> 210</td></tr></table> <p> 211<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 212<tr bgcolor="#ffc8d8"> 213<td colspan=3 valign=bottom> <br> 214<font color="#000000" face="helvetica, arial"><a name="FakePossibleBrowser">class <strong>FakePossibleBrowser</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> 215 216<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> 217<td width="100%">Methods defined here:<br> 218<dl><dt><a name="FakePossibleBrowser-Create"><strong>Create</strong></a>(self, finder_options)</dt></dl> 219 220<dl><dt><a name="FakePossibleBrowser-IsRemote"><strong>IsRemote</strong></a>(self)</dt></dl> 221 222<dl><dt><a name="FakePossibleBrowser-SetCredentialsPath"><strong>SetCredentialsPath</strong></a>(self, _)</dt></dl> 223 224<dl><dt><a name="FakePossibleBrowser-__init__"><strong>__init__</strong></a>(self)</dt></dl> 225 226<hr> 227Data descriptors defined here:<br> 228<dl><dt><strong>__dict__</strong></dt> 229<dd><tt>dictionary for instance variables (if defined)</tt></dd> 230</dl> 231<dl><dt><strong>__weakref__</strong></dt> 232<dd><tt>list of weak references to the object (if defined)</tt></dd> 233</dl> 234<dl><dt><strong>platform</strong></dt> 235<dd><tt>The platform object from the returned browser.<br> 236 <br> 237To change this or set it up, change the returned browser's<br> 238platform.</tt></dd> 239</dl> 240<dl><dt><strong>returned_browser</strong></dt> 241<dd><tt>The browser object that will be returned through later API calls.</tt></dd> 242</dl> 243</td></tr></table> <p> 244<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 245<tr bgcolor="#ffc8d8"> 246<td colspan=3 valign=bottom> <br> 247<font color="#000000" face="helvetica, arial"><a name="FakeSharedPageState">class <strong>FakeSharedPageState</strong></a>(<a href="telemetry.page.shared_page_state.html#SharedPageState">telemetry.page.shared_page_state.SharedPageState</a>)</font></td></tr> 248 249<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> 250<td width="100%"><dl><dt>Method resolution order:</dt> 251<dd><a href="telemetry.testing.fakes.html#FakeSharedPageState">FakeSharedPageState</a></dd> 252<dd><a href="telemetry.page.shared_page_state.html#SharedPageState">telemetry.page.shared_page_state.SharedPageState</a></dd> 253<dd><a href="telemetry.story.shared_state.html#SharedState">telemetry.story.shared_state.SharedState</a></dd> 254<dd><a href="__builtin__.html#object">__builtin__.object</a></dd> 255</dl> 256<hr> 257Methods defined here:<br> 258<dl><dt><a name="FakeSharedPageState-ConfigurePossibleBrowser"><strong>ConfigurePossibleBrowser</strong></a>(self, possible_browser)</dt><dd><tt>Override this to configure the PossibleBrowser.<br> 259 <br> 260Can make changes to the browser's configuration here via e.g.:<br> 261 possible_browser.returned_browser.returned_system_info = ...</tt></dd></dl> 262 263<dl><dt><a name="FakeSharedPageState-DidRunStory"><strong>DidRunStory</strong></a>(self, results)</dt></dl> 264 265<dl><dt><a name="FakeSharedPageState-__init__"><strong>__init__</strong></a>(self, test, finder_options, story_set)</dt></dl> 266 267<hr> 268Methods inherited from <a href="telemetry.page.shared_page_state.html#SharedPageState">telemetry.page.shared_page_state.SharedPageState</a>:<br> 269<dl><dt><a name="FakeSharedPageState-CanRunOnBrowser"><strong>CanRunOnBrowser</strong></a>(self, browser_info, page)</dt><dd><tt>Override this to return whether the browser brought up by this state<br> 270instance is suitable for running the given page.<br> 271 <br> 272Args:<br> 273 browser_info: an instance of telemetry.core.browser_info.BrowserInfo<br> 274 page: an instance of telemetry.page.Page</tt></dd></dl> 275 276<dl><dt><a name="FakeSharedPageState-CanRunStory"><strong>CanRunStory</strong></a>(self, page)</dt></dl> 277 278<dl><dt><a name="FakeSharedPageState-GetPregeneratedProfileArchiveDir"><strong>GetPregeneratedProfileArchiveDir</strong></a>(self)</dt></dl> 279 280<dl><dt><a name="FakeSharedPageState-RunStory"><strong>RunStory</strong></a>(self, results)</dt></dl> 281 282<dl><dt><a name="FakeSharedPageState-SetPregeneratedProfileArchiveDir"><strong>SetPregeneratedProfileArchiveDir</strong></a>(self, archive_path)</dt><dd><tt>Benchmarks can set a pre-generated profile archive to indicate that when<br> 283Chrome is launched, it should have a --user-data-dir set to the<br> 284pregenerated profile, rather than to an empty profile.<br> 285 <br> 286If the benchmark is invoked with the option --profile-dir=<dir>, that<br> 287option overrides this value.</tt></dd></dl> 288 289<dl><dt><a name="FakeSharedPageState-TearDownState"><strong>TearDownState</strong></a>(self)</dt></dl> 290 291<dl><dt><a name="FakeSharedPageState-WillRunStory"><strong>WillRunStory</strong></a>(self, page)</dt></dl> 292 293<hr> 294Data descriptors inherited from <a href="telemetry.page.shared_page_state.html#SharedPageState">telemetry.page.shared_page_state.SharedPageState</a>:<br> 295<dl><dt><strong>browser</strong></dt> 296</dl> 297<dl><dt><strong>current_page</strong></dt> 298</dl> 299<dl><dt><strong>current_tab</strong></dt> 300</dl> 301<dl><dt><strong>page_test</strong></dt> 302</dl> 303<dl><dt><strong>platform</strong></dt> 304</dl> 305<hr> 306Data descriptors inherited from <a href="telemetry.story.shared_state.html#SharedState">telemetry.story.shared_state.SharedState</a>:<br> 307<dl><dt><strong>__dict__</strong></dt> 308<dd><tt>dictionary for instance variables (if defined)</tt></dd> 309</dl> 310<dl><dt><strong>__weakref__</strong></dt> 311<dd><tt>list of weak references to the object (if defined)</tt></dd> 312</dl> 313</td></tr></table> <p> 314<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 315<tr bgcolor="#ffc8d8"> 316<td colspan=3 valign=bottom> <br> 317<font color="#000000" face="helvetica, arial"><a name="FakeSystemInfo">class <strong>FakeSystemInfo</strong></a>(<a href="telemetry.internal.platform.system_info.html#SystemInfo">telemetry.internal.platform.system_info.SystemInfo</a>)</font></td></tr> 318 319<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> 320<td width="100%"><dl><dt>Method resolution order:</dt> 321<dd><a href="telemetry.testing.fakes.html#FakeSystemInfo">FakeSystemInfo</a></dd> 322<dd><a href="telemetry.internal.platform.system_info.html#SystemInfo">telemetry.internal.platform.system_info.SystemInfo</a></dd> 323<dd><a href="__builtin__.html#object">__builtin__.object</a></dd> 324</dl> 325<hr> 326Methods defined here:<br> 327<dl><dt><a name="FakeSystemInfo-__init__"><strong>__init__</strong></a>(self, model_name<font color="#909090">=''</font>, gpu_dict<font color="#909090">=None</font>)</dt></dl> 328 329<hr> 330Class methods inherited from <a href="telemetry.internal.platform.system_info.html#SystemInfo">telemetry.internal.platform.system_info.SystemInfo</a>:<br> 331<dl><dt><a name="FakeSystemInfo-FromDict"><strong>FromDict</strong></a>(cls, attrs)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>Constructs a <a href="telemetry.internal.platform.system_info.html#SystemInfo">SystemInfo</a> from a dictionary of attributes.<br> 332Attributes currently required to be present in the dictionary:<br> 333 <br> 334 model_name (string): a platform-dependent string<br> 335 describing the model of machine, or the empty string if not<br> 336 supported.<br> 337 gpu (<a href="__builtin__.html#object">object</a> containing GPUInfo's required attributes)</tt></dd></dl> 338 339<hr> 340Data descriptors inherited from <a href="telemetry.internal.platform.system_info.html#SystemInfo">telemetry.internal.platform.system_info.SystemInfo</a>:<br> 341<dl><dt><strong>__dict__</strong></dt> 342<dd><tt>dictionary for instance variables (if defined)</tt></dd> 343</dl> 344<dl><dt><strong>__weakref__</strong></dt> 345<dd><tt>list of weak references to the object (if defined)</tt></dd> 346</dl> 347<dl><dt><strong>gpu</strong></dt> 348<dd><tt>A GPUInfo object describing the graphics processor(s) on the system.</tt></dd> 349</dl> 350<dl><dt><strong>model_name</strong></dt> 351<dd><tt>A string describing the machine model.<br> 352 <br> 353This is a highly platform-dependent value and not currently<br> 354specified for any machine type aside from Macs. On Mac OS, this<br> 355is the model identifier, reformatted slightly; for example,<br> 356'MacBookPro 10.1'.</tt></dd> 357</dl> 358</td></tr></table></td></tr></table><p> 359<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 360<tr bgcolor="#eeaa77"> 361<td colspan=3 valign=bottom> <br> 362<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr> 363 364<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td> 365<td width="100%"><dl><dt><a name="-CreateBrowserFinderOptions"><strong>CreateBrowserFinderOptions</strong></a>(browser_type<font color="#909090">=None</font>)</dt><dd><tt>Creates fake browser finder options for discovering a browser.</tt></dd></dl> 366</td></tr></table> 367</body></html>