| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Reverse Port Forwarding class to provide webpagereplay to mobile devices.""" | 5 """Reverse Port Forwarding class to provide webpagereplay to mobile devices.""" |
| 6 | 6 |
| 7 from selenium import webdriver | 7 from selenium import webdriver |
| 8 import os | 8 import os |
| 9 import sys | 9 import sys |
| 10 # TODO(chris) this path will be subject to change as we put the ispy | 10 # TODO(chris) this path will be subject to change as we put the ispy |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 self.Stop() | 48 self.Stop() |
| 49 | 49 |
| 50 def Start(self): | 50 def Start(self): |
| 51 """Sets up reverse port forwarding with a remote webdriver.""" | 51 """Sets up reverse port forwarding with a remote webdriver.""" |
| 52 # Get an adb server running for a given device. | 52 # Get an adb server running for a given device. |
| 53 self._adb = android_commands.AndroidCommands(self._device_serial) | 53 self._adb = android_commands.AndroidCommands(self._device_serial) |
| 54 self._adb.StartAdbServer() | 54 self._adb.StartAdbServer() |
| 55 # Begin forwarding the device_ports to the host_ports. | 55 # Begin forwarding the device_ports to the host_ports. |
| 56 forwarder.Forwarder.Map([(self._device_http, self._host_http), | 56 forwarder.Forwarder.Map([(self._device_http, self._host_http), |
| 57 (self._device_https, self._host_https)], | 57 (self._device_https, self._host_https)], |
| 58 self._adb, tool=None) | 58 self._adb, build_type='Release', tool=None) |
| 59 | 59 |
| 60 def Stop(self): | 60 def Stop(self): |
| 61 """Cleans up after the start call by closing the forwarder.""" | 61 """Cleans up after the start call by closing the forwarder.""" |
| 62 # shut down the forwarder. | 62 # shut down the forwarder. |
| 63 forwarder.Forwarder.UnmapDevicePort(self._device_http, self._adb) | 63 forwarder.Forwarder.UnmapDevicePort(self._device_http, self._adb) |
| 64 forwarder.Forwarder.UnmapDevicePort(self._device_https, self._adb) | 64 forwarder.Forwarder.UnmapDevicePort(self._device_https, self._adb) |
| 65 | 65 |
| 66 def GetChromeArgs(self): | 66 def GetChromeArgs(self): |
| 67 """Makes a list of arguments to enable reverse port forwarding on chrome. | 67 """Makes a list of arguments to enable reverse port forwarding on chrome. |
| 68 | 68 |
| 69 Returns: | 69 Returns: |
| 70 A list of chrome arguments to make it work with ReversePortForwarder. | 70 A list of chrome arguments to make it work with ReversePortForwarder. |
| 71 """ | 71 """ |
| 72 args = ['testing-fixed-http-port=%s' % self._device_http, | 72 args = ['testing-fixed-http-port=%s' % self._device_http, |
| 73 'testing-fixed-https-port=%s' % self._device_https, | 73 'testing-fixed-https-port=%s' % self._device_https, |
| 74 'host-resolver-rules=\"MAP * 127.0.0.1,EXCEPT, localhost\"'] | 74 'host-resolver-rules=\"MAP * 127.0.0.1,EXCEPT, localhost\"'] |
| 75 return args | 75 return args |
| OLD | NEW |