1 # Copyright 2014 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.server import autotest 6 from autotest_lib.server import site_linux_system 7 from autotest_lib.server.cros.network import hostap_config 8 from autotest_lib.server.cros.network import wifi_cell_test_base 9 from autotest_lib.client.common_lib.cros.network \ 10 import chrome_net_constants 11 12 13 class network_WiFi_RoamEndToEnd(wifi_cell_test_base.WiFiCellTestBase): 14 """Base class that configures two APs with the same SSID that will be used 15 by RoamWifiEndToEnd client test to test the UI. 16 17 The test is run in two phases. First, where we configure the first AP and 18 trigger the client test. Second, where we configure the other AP, tear 19 down the first AP and trigger the client side test again. 20 21 """ 22 version = 1 23 24 25 def _config_ap(self, channel, mode, ssid=None): 26 """Configure an AP with the given parameters. 27 28 @param channel: int Wifi channel to conduct test on. 29 @param ssid: Name to be assigned to the Wifi network. 30 @param mode: Mode for the AP configuration. 31 32 """ 33 ap_config = hostap_config.HostapConfig(channel=channel, mode=mode, 34 ssid=ssid) 35 self.context.configure(ap_config, multi_interface=True) 36 37 38 def run_once(self): 39 """Set up two APs, run the client side test and then exit. 40 41 @param host: A host object representing the DUT. 42 @param test: Test to be run on the client side. 43 44 """ 45 self.context.router.require_capabilities( 46 [site_linux_system.LinuxSystem.CAPABILITY_MULTI_AP]) 47 self.context.router.deconfig() 48 49 # Configure first AP with channel 5 and mode G and default ssid. 50 self._config_ap(5, hostap_config.HostapConfig.MODE_11G) 51 self._host = self.context.client.host 52 53 client_at = autotest.Autotest(self._host) 54 ssid = self.context.router.get_ssid(instance=0) 55 client_at.run_test('network_RoamWifiEndToEnd', 56 tag='connect', 57 ssid=ssid, 58 test=chrome_net_constants.OPEN_CONNECT) 59 # Configure second AP with channel 149, mode N and same ssid as before. 60 self._config_ap(149, hostap_config.HostapConfig.MODE_11N_PURE, ssid) 61 ssid = self.context.router.get_ssid(instance=1) 62 63 # Bring down the AP that the device is connected to. 64 self.context.router.deconfig_aps(instance=0) 65 client_at.run_test('network_RoamWifiEndToEnd', 66 tag='roam', 67 ssid=ssid, 68 test=chrome_net_constants.OPEN_ROAM) 69 70 self.context.router.deconfig() 71