def IsDevToolsAgentAvailable(port):
    """Returns True if a DevTools agent is available on the given port."""
    devtools_http_instance = devtools_http.DevToolsHttp(port)
    try:
        return _IsDevToolsAgentAvailable(devtools_http.DevToolsHttp(port))
    finally:
        devtools_http_instance.Disconnect()
  def testUrlError(self):
    class FakeProxyHandler(object):
      def __init__(self, *_, **__):
        raise urllib2.URLError('Test')

    urllib2.ProxyHandler = FakeProxyHandler
    try:
      with self.assertRaises(devtools_http.DevToolsClientUrlError):
        devtools_http.DevToolsHttp(1000).Request('')
    finally:
      urllib2.ProxyHandler = _original_proxy_handler
  def testBadStatusLine(self):
    class FakeProxyHandler(object):
      def __init__(self, *_, **__):
        raise httplib.BadStatusLine('Test')

    urllib2.ProxyHandler = FakeProxyHandler
    try:
      with self.assertRaises(devtools_http.DevToolsClientConnectionError) as e:
        devtools_http.DevToolsHttp(1000).Request('')
      self.assertNotIsInstance(e, devtools_http.DevToolsClientUrlError)
    finally:
      urllib2.ProxyHandler = _original_proxy_handler
Beispiel #4
0
  def __init__(self, devtools_port, remote_devtools_port, app_backend):
    """Creates a new DevToolsClientBackend.

    A DevTools agent must exist on the given devtools_port.

    Args:
      devtools_port: The port to use to connect to DevTools agent.
      remote_devtools_port: In some cases (e.g., app running on
          Android device, devtools_port is the forwarded port on the
          host platform. We also need to know the remote_devtools_port
          so that we can uniquely identify the DevTools agent.
      app_backend: For the app that contains the DevTools agent.
    """
    self._devtools_port = devtools_port
    self._remote_devtools_port = remote_devtools_port
    self._devtools_http = devtools_http.DevToolsHttp(devtools_port)
    self._tracing_backend = None
    self._app_backend = app_backend
    self._devtools_context_map_backend = _DevToolsContextMapBackend(
        self._app_backend, self)

    chrome_tracing_agent.ChromeTracingAgent.RegisterDevToolsClient(
      self, self._app_backend.platform_backend)
Beispiel #5
0
 def testSocketError(self):
   with self.assertRaises(devtools_http.DevToolsClientConnectionError) as e:
     devtools_http.DevToolsHttp(1000).Request('')
     self.assertnotisinstance(e, devtools_http.devtoolsclienturlerror)
Beispiel #6
0
 def testUrlError(self):
   with self.assertRaises(devtools_http.DevToolsClientUrlError):
     devtools_http.DevToolsHttp(1000).Request('')
Beispiel #7
0
def IsDevToolsAgentAvailable(port):
  """Returns True if a DevTools agent is available on the given port."""
  return _IsDevToolsAgentAvailable(devtools_http.DevToolsHttp(port))