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
5from autotest_lib.server.cros.network import wifi_cell_test_base
6
7class network_WiFi_Roam(wifi_cell_test_base.WiFiCellTestBase):
8    """Tests roaming to an AP that changes while the client is awake
9
10    This test run seeks to associate the DUT with an AP with a set of
11    association parameters, create a second AP with a second set of
12    parameters but the same SSID, and shut down the first DUT.  We
13    seek to observe that the DUT successfully connects to the second
14    AP in a reasonable amount of time.
15    """
16
17    version = 1
18
19    def parse_additional_arguments(self, commandline_args, additional_params):
20        """Hook into super class to take control files parameters.
21
22        @param commandline_args dict of parsed parameters from the autotest.
23        @param additional_params tuple of (HostapConfig,
24                                           AssociationParameters).
25
26        """
27        self._router0_conf, self._router1_conf, self._client_conf = (
28                additional_params)
29
30
31    def run_once(self):
32        """Test body."""
33        # Configure the inital AP.
34        self.context.configure(self._router0_conf)
35        router_ssid = self.context.router.get_ssid()
36
37        # Connect to the inital AP.
38        self._client_conf.ssid = router_ssid
39        self.context.assert_connect_wifi(self._client_conf)
40
41        # Setup a second AP with the same SSID.
42        self._router1_conf.ssid = router_ssid
43        self.context.configure(self._router1_conf, multi_interface=True)
44
45        # Tear down the AP instance that the DUT is currently connected to.
46        self.context.router.deconfig_aps(instance=0)
47
48        # Expect that the DUT will re-connect to the new AP.
49        self.context.wait_for_connection(router_ssid,
50                                         self._router1_conf.frequency)
51        self.context.router.deconfig()
52