1 # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 2 # Use of this source code is governed by a BSD-style license that can be 3 # found in the LICENSE file. 4 5 from autotest_lib.client.common_lib.cros.network import iw_runner 6 from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes 7 from autotest_lib.server.cros.network import hostap_config 8 from autotest_lib.server.cros.network import wifi_cell_test_base 9 10 11 class network_WiFi_Prefer5Ghz(wifi_cell_test_base.WiFiCellTestBase): 12 """Test that if we see two APs in the same network, we take the 5Ghz one.""" 13 version = 1 14 15 16 def run_once(self): 17 """Body of the test.""" 18 self.context.client.clear_supplicant_blacklist() 19 mode_n = hostap_config.HostapConfig.MODE_11N_PURE 20 ap_config0 = hostap_config.HostapConfig(channel=1, mode=mode_n) 21 self.context.configure(ap_config0) 22 ssid = self.context.router.get_ssid(instance=0) 23 ap_config1 = hostap_config.HostapConfig( 24 ssid=ssid, channel=48, mode=mode_n) 25 self.context.configure(ap_config1, multi_interface=True) 26 # Wait for both BSSes to be discovered. Since sometimes devices failed 27 # to discover both BSSes in the initial scan, which results in client 28 # connecting to the wrong BSS. 29 self.context.client.wait_for_bsses(ssid, 2) 30 self.context.assert_connect_wifi( 31 xmlrpc_datatypes.AssociationParameters(ssid=ssid)) 32 self.context.client.check_iw_link_value( 33 iw_runner.IW_LINK_KEY_FREQUENCY, 34 str(ap_config1.frequency)) 35