Index: chrome/test/pyautolib/pyauto.py |
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py |
index 7d81e0a5505eb541b3be13288254f700d898a2ec..83bc88f02ec10dad76dafe96905285c3f4338129 100755 |
--- a/chrome/test/pyautolib/pyauto.py |
+++ b/chrome/test/pyautolib/pyauto.py |
@@ -4496,42 +4496,6 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): |
return panels |
- def RestoreOnline(self): |
- """Returns the device from offline mode if GoOffline was used.""" |
- |
- assert PyUITest.IsChromeOS() |
- |
- # Restores etherent connection |
- stdout, stderr = self.RunSuperuserActionOnChromeOS('TeardownBackchannel') |
- |
- if hasattr(self, 'bc_cellular_enabled') and self.bc_cellular_enabled: |
- self.ToggleNetworkDevice('cellular', True) |
- if hasattr(self, 'bc_wifi_enabled') and self.bc_wifi_enabled: |
- self.ToggleNetworkDevice('wifi', True) |
- |
- assert 'RuntimeError' not in stderr, stderr |
- |
- def GoOffline(self): |
- """Puts device in offline mode. |
- |
- The device is put into offline mode by disabling all network interfaces |
- but keeping the the wired ethernet interface up and faking shill/flimflam |
- into thinking there is no ethernet interface by renaming the interface. |
- This is so we can keep ssh connections over the wired connection alive. |
- """ |
- assert PyUITest.IsChromeOS() |
- net_info = self.GetNetworkInfo() |
- self.bc_wifi_enabled = net_info.get('wifi_enabled') |
- self.bc_cellular_enabled = net_info.get('cellular_enabled') |
- |
- if self.bc_cellular_enabled: |
- self.ToggleNetworkDevice('cellular', False) |
- if self.bc_wifi_enabled: |
- self.ToggleNetworkDevice('wifi', False) |
- |
- stdout, stderr = self.RunSuperuserActionOnChromeOS('SetupBackchannel') |
- assert 'RuntimeError' not in stderr, stderr |
- |
def GetNetworkInfo(self): |
"""Get details about ethernet, wifi, and cellular networks on chromeos. |
@@ -4596,52 +4560,6 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): |
return network_info |
- def GetConnectedWifi(self): |
- """Returns the SSID of the currently connected wifi network. |
- |
- Returns: |
- The SSID of the connected network or None if we're not connected. |
- """ |
- service_list = self.GetNetworkInfo() |
- connected_service_path = service_list.get('connected_wifi') |
- if 'wifi_networks' in service_list and \ |
- connected_service_path in service_list['wifi_networks']: |
- return service_list['wifi_networks'][connected_service_path]['name'] |
- |
- def GetServicePath(self, ssid, encryption=None, timeout=30): |
- """Waits until the SSID is observed and returns its service path. |
- |
- Args: |
- ssid: String defining the SSID we are searching for. |
- encryption: Encryption type of the network; either None to return the |
- first instance of network that matches the ssid, '' for |
- an empty network, 'PSK', 'WEP' or '8021X'. |
- timeout: Duration to wait for ssid to appear. |
- |
- Returns: |
- The service path or None if SSID does not exist after timeout period. |
- """ |
- def _GetServicePath(): |
- service_list = self.GetNetworkInfo().get('wifi_networks', []) |
- for service_path, service_obj in service_list.iteritems(): |
- if not (isinstance(service_obj, dict) and |
- 'encryption' in service_obj and |
- 'name' in service_obj): |
- continue |
- |
- service_encr = 'PSK' if service_obj['encryption'] in ['WPA', 'RSN']\ |
- else service_obj['encryption'] |
- |
- if service_obj['name'] == ssid and \ |
- (encryption == None or service_encr == encryption): |
- return service_path |
- self.NetworkScan() |
- return None |
- |
- service_path = self.WaitUntil(_GetServicePath, timeout=timeout, |
- retry_sleep=1, return_retval=True) |
- return service_path or None |
- |
def NetworkScan(self): |
"""Causes ChromeOS to scan for available wifi networks. |
@@ -4672,90 +4590,6 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): |
} |
return self._GetResultFromJSONRequest(cmd_dict, windex=None) |
- PROXY_TYPE_DIRECT = 1 |
- PROXY_TYPE_MANUAL = 2 |
- PROXY_TYPE_PAC = 3 |
- |
- def WaitUntilWifiNetworkAvailable(self, ssid, timeout=60, is_hidden=False): |
- """Waits until the given network is available. |
- |
- Routers that are just turned on may take up to 1 minute upon turning them |
- on to broadcast their SSID. |
- |
- Args: |
- ssid: SSID of the service we want to connect to. |
- timeout: timeout (in seconds) |
- |
- Raises: |
- Exception if timeout duration has been hit before wifi router is seen. |
- |
- Returns: |
- True, when the wifi network is seen within the timout period. |
- False, otherwise. |
- """ |
- def _GotWifiNetwork(): |
- # Returns non-empty array if desired SSID is available. |
- try: |
- return [wifi for wifi in |
- self.NetworkScan().get('wifi_networks', {}).values() |
- if wifi.get('name') == ssid] |
- except pyauto_errors.JSONInterfaceError: |
- # Temporary fix until crosbug.com/14174 is fixed. |
- # NetworkScan is only used in updating the list of networks so errors |
- # thrown by it are not critical to the results of wifi tests that use |
- # this method. |
- return False |
- |
- # The hidden AP's will always be on, thus we will assume it is ready to |
- # connect to. |
- if is_hidden: |
- return bool(_GotWifiNetwork()) |
- |
- return self.WaitUntil(_GotWifiNetwork, timeout=timeout, retry_sleep=1) |
- |
- def ResetProxySettingsOnChromeOS(self): |
- """Public wrapper around proxysettings teardown functions.""" |
- self.SetSharedProxies(False) |
- proxy_dict = { |
- 'mode': 'direct' |
- } |
- self.SetProxySettingOnChromeOS(proxy_dict) |
- |
- def SetProxySettingOnChromeOS(self, proxy_config): |
- """Set the proxy config of the current network. |
- |
- Owner must be logged in for these to persist. |
- If user is not logged in or is logged in as non-owner or guest, |
- proxy settings do not persist across browser restarts or login/logout. |
- |
- Args: |
- proxy_config: A dictionary following the format described in |
- prefs/proxy_config_dictionary.h. |
- |
- Raises: |
- pyauto_errors.JSONInterfaceError if the automation call returns an error. |
- """ |
- cmd_dict = { |
- 'command': 'SetProxySettings', |
- 'proxy_config': json.dumps(proxy_config) |
- } |
- return self._GetResultFromJSONRequest(cmd_dict, windex=None) |
- |
- def SetSharedProxies(self, value): |
- """Allows proxies on the shared networks. |
- |
- Args: |
- value: True/False to set and clear respectively. |
- |
- Raises: |
- pyauto_errors.JSONInterfaceError if the automation call returns an error. |
- """ |
- cmd_dict = { |
- 'command': 'SetSharedProxies', |
- 'value': value, |
- } |
- return self._GetResultFromJSONRequest(cmd_dict, windex=None) |
- |
def ForgetAllRememberedNetworks(self): |
"""Forgets all networks that the device has marked as remembered.""" |
for service in self.GetNetworkInfo()['remembered_wifi']: |
@@ -4786,72 +4620,6 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): |
} |
self._GetResultFromJSONRequest(cmd_dict, windex=None, timeout=50000) |
- def ConnectToCellularNetwork(self): |
- """Connects to the available cellular network. |
- |
- Blocks until connection succeeds or fails. |
- |
- Returns: |
- An error string if an error occured. |
- None otherwise. |
- |
- Raises: |
- pyauto_errors.JSONInterfaceError if the automation call returns an error. |
- """ |
- # Every device should only have one cellular network present, so we can |
- # scan for it. |
- cellular_networks = self.NetworkScan().get('cellular_networks', {}).keys() |
- self.assertTrue(cellular_networks, 'Could not find cellular service.') |
- service_path = cellular_networks[0] |
- |
- cmd_dict = { |
- 'command': 'ConnectToCellularNetwork', |
- 'service_path': service_path, |
- } |
- result = self._GetResultFromJSONRequest( |
- cmd_dict, windex=None, timeout=50000) |
- return result.get('error_string') |
- |
- def DisconnectFromCellularNetwork(self): |
- """Disconnect from the connected cellular network. |
- |
- Blocks until disconnect is complete. |
- |
- Raises: |
- pyauto_errors.JSONInterfaceError if the automation call returns an error. |
- """ |
- cmd_dict = { |
- 'command': 'DisconnectFromCellularNetwork', |
- } |
- self._GetResultFromJSONRequest(cmd_dict, windex=None) |
- |
- def ConnectToWifiNetwork(self, service_path, password='', shared=True): |
- """Connect to a wifi network by its service path. |
- |
- Blocks until connection succeeds or fails. |
- |
- Args: |
- service_path: Flimflam path that defines the wifi network. |
- password: Passphrase for connecting to the wifi network. |
- shared: Boolean value specifying whether the network should be shared. |
- |
- Returns: |
- An error string if an error occured. |
- None otherwise. |
- |
- Raises: |
- pyauto_errors.JSONInterfaceError if the automation call returns an error. |
- """ |
- cmd_dict = { |
- 'command': 'ConnectToWifiNetwork', |
- 'service_path': service_path, |
- 'password': password, |
- 'shared': shared, |
- } |
- result = self._GetResultFromJSONRequest( |
- cmd_dict, windex=None, timeout=50000) |
- return result.get('error_string') |
- |
def ConnectToHiddenWifiNetwork(self, ssid, security, password='', |
shared=True, save_credentials=False): |
"""Connect to a wifi network by its service path. |
@@ -4888,134 +4656,6 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): |
cmd_dict, windex=None, timeout=50000) |
return result.get('error_string') |
- def DisconnectFromWifiNetwork(self): |
- """Disconnect from the connected wifi network. |
- |
- Blocks until disconnect is complete. |
- |
- Raises: |
- pyauto_errors.JSONInterfaceError if the automation call returns an error. |
- """ |
- cmd_dict = { |
- 'command': 'DisconnectFromWifiNetwork', |
- } |
- self._GetResultFromJSONRequest(cmd_dict, windex=None) |
- |
- def AddPrivateNetwork(self, |
- hostname, |
- service_name, |
- provider_type, |
- username, |
- password, |
- cert_id='', |
- key=''): |
- """Add and connect to a private network. |
- |
- Blocks until connection succeeds or fails. This is equivalent to |
- 'Add Private Network' in the network menu UI. |
- |
- Args: |
- hostname: Server hostname for the private network. |
- service_name: Service name that defines the private network. Do not |
- add multiple services with the same name. |
- provider_type: Types are L2TP_IPSEC_PSK and L2TP_IPSEC_USER_CERT. |
- Provider type OPEN_VPN is not yet supported. |
- Type names returned by GetPrivateNetworkInfo will |
- also work. |
- username: Username for connecting to the virtual network. |
- password: Passphrase for connecting to the virtual network. |
- cert_id: Certificate id for a L2TP_IPSEC_USER_CERT network. |
- key: Pre-shared key for a L2TP_IPSEC_PSK network. |
- |
- Returns: |
- An error string if an error occured. |
- None otherwise. |
- |
- Raises: |
- pyauto_errors.JSONInterfaceError if the automation call returns an error. |
- """ |
- cmd_dict = { |
- 'command': 'AddPrivateNetwork', |
- 'hostname': hostname, |
- 'service_name': service_name, |
- 'provider_type': provider_type, |
- 'username': username, |
- 'password': password, |
- 'cert_id': cert_id, |
- 'key': key, |
- } |
- result = self._GetResultFromJSONRequest( |
- cmd_dict, windex=None, timeout=50000) |
- return result.get('error_string') |
- |
- def GetPrivateNetworkInfo(self): |
- """Get details about private networks on chromeos. |
- |
- Returns: |
- A dictionary including information about all remembered virtual networks |
- as well as the currently connected virtual network, if any. |
- Sample: |
- { u'connected': u'/service/vpn_123_45_67_89_test_vpn'} |
- u'/service/vpn_123_45_67_89_test_vpn': |
- { u'username': u'vpn_user', |
- u'name': u'test_vpn', |
- u'hostname': u'123.45.67.89', |
- u'key': u'abcde', |
- u'cert_id': u'', |
- u'password': u'zyxw123', |
- u'provider_type': u'L2TP_IPSEC_PSK'}, |
- u'/service/vpn_111_11_11_11_test_vpn2': |
- { u'username': u'testerman', |
- u'name': u'test_vpn2', |
- u'hostname': u'111.11.11.11', |
- u'key': u'fghijklm', |
- u'cert_id': u'', |
- u'password': u'789mnop', |
- u'provider_type': u'L2TP_IPSEC_PSK'}, |
- |
- Raises: |
- pyauto_errors.JSONInterfaceError if the automation call returns an error. |
- """ |
- cmd_dict = { 'command': 'GetPrivateNetworkInfo' } |
- return self._GetResultFromJSONRequest(cmd_dict, windex=None) |
- |
- def ConnectToPrivateNetwork(self, service_path): |
- """Connect to a remembered private network by its service path. |
- |
- Blocks until connection succeeds or fails. The network must have been |
- previously added with all necessary connection details. |
- |
- Args: |
- service_path: Service name that defines the private network. |
- |
- Returns: |
- An error string if an error occured. |
- None otherwise. |
- |
- Raises: |
- pyauto_errors.JSONInterfaceError if the automation call returns an error. |
- """ |
- cmd_dict = { |
- 'command': 'ConnectToPrivateNetwork', |
- 'service_path': service_path, |
- } |
- result = self._GetResultFromJSONRequest( |
- cmd_dict, windex=None, timeout=50000) |
- return result.get('error_string') |
- |
- def DisconnectFromPrivateNetwork(self): |
- """Disconnect from the active private network. |
- |
- Expects a private network to be active. |
- |
- Raises: |
- pyauto_errors.JSONInterfaceError if the automation call returns an error. |
- """ |
- cmd_dict = { |
- 'command': 'DisconnectFromPrivateNetwork', |
- } |
- return self._GetResultFromJSONRequest(cmd_dict, windex=None) |
- |
def EnableSpokenFeedback(self, enabled): |
"""Enables or disables spoken feedback accessibility mode. |