Index: chrome/test/pyautolib/pyauto.py |
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py |
index 83bc88f02ec10dad76dafe96905285c3f4338129..ee58d7df5e4f2a543b1934faab4cff146a27e2fd 100755 |
--- a/chrome/test/pyautolib/pyauto.py |
+++ b/chrome/test/pyautolib/pyauto.py |
@@ -208,10 +208,6 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): |
if not self.IsChromeOS(): |
self.GetPluginsInfo() |
- # TODO(dtu): Remove this after crosbug.com/4558 is fixed. |
- if self.IsChromeOS(): |
- self.WaitUntil(lambda: not self.GetNetworkInfo()['offline_mode']) |
- |
if (self.IsChromeOS() and not self.GetLoginInfo()['is_logged_in'] and |
self.ShouldOOBESkipToLogin()): |
if self.GetOOBEScreenInfo()['screen_name'] != 'login': |
@@ -4496,166 +4492,6 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): |
return panels |
- def GetNetworkInfo(self): |
- """Get details about ethernet, wifi, and cellular networks on chromeos. |
- |
- Returns: |
- A dictionary. |
- Sample: |
- { u'cellular_available': True, |
- u'cellular_enabled': False, |
- u'connected_ethernet': u'/service/ethernet_abcd', |
- u'connected_wifi': u'/service/wifi_abcd_1234_managed_none', |
- u'ethernet_available': True, |
- u'ethernet_enabled': True, |
- u'ethernet_networks': |
- { u'/service/ethernet_abcd': |
- { u'device_path': u'/device/abcdeth', |
- u'name': u'', |
- u'service_path': |
- u'/profile/default/ethernet_abcd', |
- u'status': u'Connected'} |
- u'network_type': pyautolib.TYPE_ETHERNET }, |
- u'remembered_wifi': |
- { u'/service/wifi_abcd_1234_managed_none': |
- { u'device_path': u'', |
- u'encrypted': False, |
- u'encryption': u'', |
- u'name': u'WifiNetworkName1', |
- u'status': u'Unknown', |
- u'strength': 0}, |
- u'network_type': pyautolib.TYPE_WIFI |
- }, |
- u'wifi_available': True, |
- u'wifi_enabled': True, |
- u'wifi_networks': |
- { u'/service/wifi_abcd_1234_managed_none': |
- { u'device_path': u'/device/abcdwifi', |
- u'encrypted': False, |
- u'encryption': u'', |
- u'name': u'WifiNetworkName1', |
- u'status': u'Connected', |
- u'strength': 76}, |
- u'/service/wifi_abcd_1234_managed_802_1x': |
- { u'encrypted': True, |
- u'encryption': u'8021X', |
- u'name': u'WifiNetworkName2', |
- u'status': u'Idle', |
- u'strength': 79} |
- u'network_type': pyautolib.TYPE_WIFI }} |
- |
- |
- Raises: |
- pyauto_errors.JSONInterfaceError if the automation call returns an error. |
- """ |
- cmd_dict = { 'command': 'GetNetworkInfo' } |
- network_info = self._GetResultFromJSONRequest(cmd_dict, windex=None) |
- |
- # Remembered networks do not have /service/ prepended to the service path |
- # even though wifi_networks does. We want this prepended to allow for |
- # consistency and easy string comparison with wifi_networks. |
- remembered_wifi = {} |
- network_info['remembered_wifi'] = dict([('/service/' + k, v) for k, v in |
- network_info['remembered_wifi'].iteritems()]) |
- |
- return network_info |
- |
- def NetworkScan(self): |
- """Causes ChromeOS to scan for available wifi networks. |
- |
- Blocks until scanning is complete. |
- |
- Returns: |
- The new list of networks obtained from GetNetworkInfo(). |
- |
- Raises: |
- pyauto_errors.JSONInterfaceError if the automation call returns an error. |
- """ |
- cmd_dict = { 'command': 'NetworkScan' } |
- self._GetResultFromJSONRequest(cmd_dict, windex=None) |
- return self.GetNetworkInfo() |
- |
- def ToggleNetworkDevice(self, device, enable): |
- """Enable or disable a network device on ChromeOS. |
- |
- Valid device names are ethernet, wifi, cellular. |
- |
- Raises: |
- pyauto_errors.JSONInterfaceError if the automation call returns an error. |
- """ |
- cmd_dict = { |
- 'command': 'ToggleNetworkDevice', |
- 'device': device, |
- 'enable': enable, |
- } |
- 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']: |
- self.ForgetWifiNetwork(service) |
- |
- def ForgetWifiNetwork(self, service_path): |
- """Forget a remembered network by its service path. |
- |
- This function is equivalent to clicking the 'Forget Network' button in the |
- chrome://settings/internet page. This function does not indicate whether |
- or not forget succeeded or failed. It is up to the caller to call |
- GetNetworkInfo to check the updated remembered_wifi list to verify the |
- service has been removed. |
- |
- Args: |
- service_path: Flimflam path that defines the remembered network. |
- |
- Raises: |
- pyauto_errors.JSONInterfaceError if the automation call returns an error. |
- """ |
- # Usually the service_path is prepended with '/service/', such as when the |
- # service path is retrieved from GetNetworkInfo. ForgetWifiNetwork works |
- # only for service paths where this has already been stripped. |
- service_path = service_path.split('/service/')[-1] |
- cmd_dict = { |
- 'command': 'ForgetWifiNetwork', |
- 'service_path': service_path, |
- } |
- self._GetResultFromJSONRequest(cmd_dict, windex=None, timeout=50000) |
- |
- def ConnectToHiddenWifiNetwork(self, ssid, security, password='', |
- shared=True, save_credentials=False): |
- """Connect to a wifi network by its service path. |
- |
- Blocks until connection succeeds or fails. |
- |
- Args: |
- ssid: The SSID of the network to connect to. |
- security: The network's security type. One of: 'SECURITY_NONE', |
- 'SECURITY_WEP', 'SECURITY_WPA', 'SECURITY_RSN', 'SECURITY_8021X' |
- password: Passphrase for connecting to the wifi network. |
- shared: Boolean value specifying whether the network should be shared. |
- save_credentials: Boolean value specifying whether 802.1x credentials are |
- saved. |
- |
- Returns: |
- An error string if an error occured. |
- None otherwise. |
- |
- Raises: |
- pyauto_errors.JSONInterfaceError if the automation call returns an error. |
- """ |
- assert security in ('SECURITY_NONE', 'SECURITY_WEP', 'SECURITY_WPA', |
- 'SECURITY_RSN', 'SECURITY_8021X') |
- cmd_dict = { |
- 'command': 'ConnectToHiddenWifiNetwork', |
- 'ssid': ssid, |
- 'security': security, |
- 'password': password, |
- 'shared': shared, |
- 'save_credentials': save_credentials, |
- } |
- result = self._GetResultFromJSONRequest( |
- cmd_dict, windex=None, timeout=50000) |
- return result.get('error_string') |
- |
def EnableSpokenFeedback(self, enabled): |
"""Enables or disables spoken feedback accessibility mode. |