• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2#   Copyright 2017 - The Android Open Source Project
3#
4#   Licensed under the Apache License, Version 2.0 (the "License");
5#   you may not use this file except in compliance with the License.
6#   You may obtain a copy of the License at
7#
8#       http://www.apache.org/licenses/LICENSE-2.0
9#
10#   Unless required by applicable law or agreed to in writing, software
11#   distributed under the License is distributed on an "AS IS" BASIS,
12#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13#   See the License for the specific language governing permissions and
14#   limitations under the License.
15
16import pprint
17import random
18import time
19
20from acts import asserts
21from acts import base_test
22from acts import signals
23from acts.test_decorators import test_tracker_info
24from acts.test_utils.wifi import wifi_test_utils as wutils
25from acts.test_utils.wifi.WifiBaseTest import WifiBaseTest
26
27WifiEnums = wutils.WifiEnums
28
29class WifiRoamingTest(WifiBaseTest):
30
31    def __init__(self, controllers):
32        WifiBaseTest.__init__(self, controllers)
33
34    def setup_class(self):
35        """Setup required dependencies from config file and configure
36           the required networks for testing roaming.
37
38        Returns:
39            True if successfully configured the requirements for testing.
40        """
41        self.dut = self.android_devices[0]
42        wutils.wifi_test_device_init(self.dut)
43        req_params = ("roaming_attn", "roam_interval", "ping_addr", "max_bugreports")
44        opt_param = [
45            "open_network", "reference_networks", "iperf_server_address"]
46        self.unpack_userparams(
47            req_param_names=req_params, opt_param_names=opt_param)
48
49        if "AccessPoint" in self.user_params:
50            self.legacy_configure_ap_and_start(ap_count=2)
51
52        asserts.assert_true(
53            len(self.reference_networks) > 1,
54            "Need at least two psk networks for roaming.")
55        asserts.assert_true(
56            len(self.open_network) > 1,
57            "Need at least two open networks for roaming")
58        wutils.wifi_toggle_state(self.dut, True)
59        if "iperf_server_address" in self.user_params:
60            self.iperf_server = self.iperf_servers[0]
61            self.iperf_server.start()
62
63    def teardown_class(self):
64        self.dut.ed.clear_all_events()
65        if "AccessPoint" in self.user_params:
66            del self.user_params["reference_networks"]
67            del self.user_params["open_network"]
68        self.iperf_server.stop()
69
70    def setup_test(self):
71        self.dut.droid.wakeLockAcquireBright()
72        self.dut.droid.wakeUpNow()
73
74    def teardown_test(self):
75        self.dut.droid.wakeLockRelease()
76        self.dut.droid.goToSleepNow()
77        wutils.reset_wifi(self.dut)
78
79    def on_fail(self, test_name, begin_time):
80        self.dut.cat_adb_log(test_name, begin_time)
81        self.dut.take_bug_report(test_name, begin_time)
82
83    def roaming_from_AP1_and_AP2(self, AP1_network, AP2_network):
84        """Test roaming between two APs.
85
86        Args:
87            AP1_network: AP-1's network information.
88            AP2_network: AP-2's network information.
89
90        Steps:
91        1. Make AP1 visible, AP2 not visible.
92        2. Connect to AP1's ssid.
93        3. Make AP1 not visible, AP2 visible.
94        4. Expect DUT to roam to AP2.
95        5. Validate connection information and ping.
96        """
97        wutils.set_attns(self.attenuators, "AP1_on_AP2_off")
98        wutils.wifi_connect(self.dut, AP1_network)
99        self.log.info("Roaming from %s to %s", AP1_network, AP2_network)
100        wutils.trigger_roaming_and_validate(self.dut, self.attenuators,
101            "AP1_off_AP2_on", AP2_network)
102
103    """ Tests Begin.
104
105        The following tests are designed to test inter-SSID Roaming only.
106
107        """
108    @test_tracker_info(uuid="db8a46f9-713f-4b98-8d9f-d36319905b0a")
109    def test_roaming_between_AP1_to_AP2_open_2g(self):
110        AP1_network = self.open_network[0]["2g"]
111        AP2_network = self.open_network[1]["2g"]
112        self.roaming_from_AP1_and_AP2(AP1_network, AP2_network)
113
114    @test_tracker_info(uuid="0db67d9b-6ea9-4f40-acf2-155c4ecf9dc5")
115    def test_roaming_between_AP1_to_AP2_open_5g(self):
116        AP1_network = self.open_network[0]["5g"]
117        AP2_network = self.open_network[1]["5g"]
118        self.roaming_from_AP1_and_AP2(AP1_network, AP2_network)
119
120    @test_tracker_info(uuid="eabc7319-d962-4bef-b679-725e9ff00420")
121    def test_roaming_between_AP1_to_AP2_psk_2g(self):
122        AP1_network = self.reference_networks[0]["2g"]
123        AP2_network = self.reference_networks[1]["2g"]
124        self.roaming_from_AP1_and_AP2(AP1_network, AP2_network)
125
126    @test_tracker_info(uuid="1cf9c681-4ff0-45c1-9719-f01629f6a7f7")
127    def test_roaming_between_AP1_to_AP2_psk_5g(self):
128        AP1_network = self.reference_networks[0]["5g"]
129        AP2_network = self.reference_networks[1]["5g"]
130        self.roaming_from_AP1_and_AP2(AP1_network, AP2_network)
131
132    @test_tracker_info(uuid="3114d625-5cdd-4205-bb46-5a9d057dc80d")
133    def test_roaming_fail_psk_2g(self):
134        network = {'SSID':'test_roaming_fail', 'password':'roam123456@'}
135        # AP2 network with incorrect password.
136        network_fail = {'SSID':'test_roaming_fail', 'password':'roam123456@#$%^'}
137        # Setup AP1 with the correct password.
138        wutils.ap_setup(self, 0, self.access_points[0], network)
139        network_bssid = self.access_points[0].get_bssid_from_ssid(
140                network["SSID"], '2g')
141        # Setup AP2 with the incorrect password.
142        wutils.ap_setup(self, 1, self.access_points[1], network_fail)
143        network_fail_bssid = self.access_points[1].get_bssid_from_ssid(
144                network_fail["SSID"], '2g')
145        network['bssid'] = network_bssid
146        network_fail['bssid'] = network_fail_bssid
147        try:
148            # Initiate roaming with AP2 configured with incorrect password.
149            self.roaming_from_AP1_and_AP2(network, network_fail)
150        except:
151            self.log.info("Roaming failed to AP2 with incorrect password.")
152            # Re-configure AP2 after roaming failed, with correct password.
153            self.log.info("Re-configuring AP2 with correct password.")
154            wutils.ap_setup(self, 1, self.access_points[1], network)
155        self.roaming_from_AP1_and_AP2(network, network_fail)
156
157    """ Tests End """
158