| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 import logging | |
| 7 | |
| 8 import pyauto_functional | |
| 9 import chromeos_network # pyauto_functional must come before chromeos_network | |
| 10 | |
| 11 | |
| 12 class ChromeosWifiSanity(chromeos_network.PyNetworkUITest): | |
| 13 """Tests for ChromeOS network related functions.""" | |
| 14 | |
| 15 def testToggleNetworkDevice(self): | |
| 16 """Sanity check to make sure wifi can be disabled and reenabled.""" | |
| 17 self.ToggleNetworkDevice('wifi', False) | |
| 18 self.assertFalse(self.GetNetworkInfo()['wifi_enabled'], | |
| 19 'Disabled wifi but it is still enabled.') | |
| 20 self.assertFalse('wifi_networks' in self.GetNetworkInfo(), 'GetNetworkInfo ' | |
| 21 'returned a wifi_networks dict, but wifi is disabled.') | |
| 22 self.ToggleNetworkDevice("wifi", True) | |
| 23 self.assertTrue(self.GetNetworkInfo()['wifi_enabled'], | |
| 24 'Enabled wifi but it is still disabled.') | |
| 25 self.assertTrue('wifi_networks' in self.GetNetworkInfo(), 'GetNetworkInfo ' | |
| 26 'did not return a wifi_networks dict.') | |
| 27 | |
| 28 def testConnectToHiddenWiFiNonExistent(self): | |
| 29 """Connecting to a non-existent network should fail. | |
| 30 | |
| 31 Assume network 'ThisIsANonExistentNetwork' is not a valid ssid within | |
| 32 the vicinity of where this test is run. | |
| 33 """ | |
| 34 ssid = 'ThisIsANonExistentNetwork' | |
| 35 error = self.ConnectToHiddenWifiNetwork(ssid, 'SECURITY_NONE') | |
| 36 self.assertTrue(error is not None, msg='Device connected to a non-existent ' | |
| 37 'network "%s".' % ssid) | |
| 38 self.assertTrue(error != '', msg='Device had a connection error but no ' | |
| 39 'error message.') | |
| 40 | |
| 41 def testForgetWifiNetwork(self): | |
| 42 """Basic test to verify there are no problems calling ForgetWifiNetwork.""" | |
| 43 self.ForgetAllRememberedNetworks() | |
| 44 # This call should have no problems regardless of whether or not | |
| 45 # the network exists. | |
| 46 self.ForgetWifiNetwork('') | |
| 47 self.assertFalse(self.GetNetworkInfo()['remembered_wifi'], 'All ' | |
| 48 'remembered wifi networks should have been removed') | |
| 49 | |
| 50 | |
| 51 if __name__ == '__main__': | |
| 52 pyauto_functional.Main() | |
| OLD | NEW |