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 import logging 6 import time 7 8 from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes 9 from autotest_lib.server.cros.network import wifi_cell_test_base 10 11 class network_WiFi_RoamSuspendSSID(wifi_cell_test_base.WiFiCellTestBase): 12 """Tests roaming to a new SSID when a previous SSID disappears in suspend. 13 14 This test: 15 1) Connects the DUT to a network A 16 2) Connects the DUT to a network B while keeping network A around. 17 3) Suspend the DUT (while connected to network B). 18 4) Deconfigure (take down) network B. 19 5) Assert that the DUT automatically connects to network A on resume. 20 21 """ 22 23 version = 1 24 25 SUSPEND_TIME_SECONDS = 15 26 27 28 def parse_additional_arguments(self, commandline_args, additional_params): 29 """Hook into super class to take control files parameters. 30 31 @param commandline_args: dict of parsed parameters from the autotest. 32 @param additional_params: tuple(HostapConfig, HostapConfig) used as 33 networks A and B from the test description. 34 35 """ 36 self._ap_config0 = additional_params[0] 37 self._ap_config1 = additional_params[1] 38 39 40 def run_once(self): 41 """Test body.""" 42 get_client_config = lambda ssid, ap_config: \ 43 xmlrpc_datatypes.AssociationParameters( 44 ssid=ssid, 45 security_config=ap_config.security_config) 46 self.context.configure(self._ap_config0) 47 self.context.configure(self._ap_config1, multi_interface=True) 48 self.context.assert_connect_wifi( 49 get_client_config(self.context.router.get_ssid(instance=0), 50 self._ap_config0)) 51 self.context.assert_connect_wifi( 52 get_client_config(self.context.router.get_ssid(instance=1), 53 self._ap_config1)) 54 self.context.client.do_suspend_bg(self.SUSPEND_TIME_SECONDS + 5) 55 logging.info('Waiting %d seconds for DUT to be fully suspended.', 56 self.SUSPEND_TIME_SECONDS) 57 time.sleep(self.SUSPEND_TIME_SECONDS) 58 logging.info('Tearing down the most recently connected AP.') 59 self.context.router.deconfig_aps(instance=1) 60 logging.info('Expect that we connect to our previous connected AP ' 61 'on resume.') 62 self.context.wait_for_connection( 63 self.context.router.get_ssid(instance=0), 64 self._ap_config0.frequency) 65