Qi Jiang | 2a128de | 2018-04-27 23:00:12 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python3.4 |
| 2 | # |
| 3 | # Copyright 2018 - The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the 'License'); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an 'AS IS' BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
Qi Jiang | ddd0114 | 2018-10-18 22:51:42 -0700 | [diff] [blame^] | 17 | import copy |
Qi Jiang | 2a128de | 2018-04-27 23:00:12 -0700 | [diff] [blame] | 18 | import time |
| 19 | from acts import utils |
| 20 | from acts.controllers.ap_lib import hostapd_constants as hc |
| 21 | from acts.test_decorators import test_tracker_info |
| 22 | from acts.test_utils.power import PowerWiFiBaseTest as PWBT |
| 23 | from acts.test_utils.wifi import wifi_constants as wc |
| 24 | from acts.test_utils.wifi import wifi_test_utils as wutils |
| 25 | from acts.test_utils.wifi import wifi_power_test_utils as wputils |
| 26 | |
| 27 | |
| 28 | class PowerWiFiroamingTest(PWBT.PowerWiFiBaseTest): |
Qi Jiang | ddd0114 | 2018-10-18 22:51:42 -0700 | [diff] [blame^] | 29 | def teardown_test(self): |
| 30 | # Delete the brconfigs attributes as this is duplicated with one of the |
| 31 | # ap's bridge interface config |
| 32 | delattr(self, 'brconfigs') |
| 33 | super().teardown_test() |
Qi Jiang | 2a128de | 2018-04-27 23:00:12 -0700 | [diff] [blame] | 34 | |
| 35 | # Test cases |
| 36 | @test_tracker_info(uuid='392622d3-0c5c-4767-afa2-abfb2058b0b8') |
| 37 | def test_screenoff_roaming(self): |
| 38 | """Test roaming power consumption with screen off. |
| 39 | Change the attenuation level to trigger roaming between two APs |
| 40 | |
| 41 | """ |
Qi Jiang | 2a128de | 2018-04-27 23:00:12 -0700 | [diff] [blame] | 42 | # Setup both APs |
Qi Jiang | ddd0114 | 2018-10-18 22:51:42 -0700 | [diff] [blame^] | 43 | network_main = copy.deepcopy(self.main_network)[hc.BAND_2G] |
| 44 | network_aux = copy.deepcopy(self.aux_network)[hc.BAND_2G] |
| 45 | self.log.info('Set attenuation to connect device to the aux AP') |
| 46 | self.set_attenuation(self.atten_level[wc.AP_AUX]) |
| 47 | self.brconfigs_aux = self.setup_ap_connection( |
| 48 | network_aux, ap=self.access_point_aux) |
| 49 | self.log.info('Set attenuation to connect device to the main AP') |
| 50 | self.set_attenuation(self.atten_level[wc.AP_MAIN]) |
| 51 | self.brconfigs_main = self.setup_ap_connection( |
| 52 | network_main, ap=self.access_point_main) |
Qi Jiang | 2a128de | 2018-04-27 23:00:12 -0700 | [diff] [blame] | 53 | self.dut.droid.goToSleepNow() |
| 54 | time.sleep(5) |
| 55 | # Set attenuator to trigger roaming |
| 56 | self.dut.log.info('Trigger roaming now') |
| 57 | self.set_attenuation(self.atten_level[self.current_test_name]) |
| 58 | self.measure_power_and_validate() |
| 59 | |
| 60 | @test_tracker_info(uuid='2fec5208-043a-410a-8fd2-6784d70a3587') |
| 61 | def test_screenoff_fastroaming(self): |
| 62 | |
| 63 | # Setup the aux AP |
Qi Jiang | ddd0114 | 2018-10-18 22:51:42 -0700 | [diff] [blame^] | 64 | network_main = copy.deepcopy(self.main_network)[hc.BAND_2G] |
| 65 | network_aux = copy.deepcopy(self.aux_network)[hc.BAND_2G] |
Qi Jiang | 2a128de | 2018-04-27 23:00:12 -0700 | [diff] [blame] | 66 | # Set the same SSID for the AUX AP for fastroaming purpose |
| 67 | network_aux[wc.SSID] = network_main[wc.SSID] |
| 68 | # Set attenuator to connect the phone to the aux AP |
| 69 | self.log.info('Set attenuation to connect device to the aux AP') |
| 70 | self.set_attenuation(self.atten_level[wc.AP_AUX]) |
Qi Jiang | ddd0114 | 2018-10-18 22:51:42 -0700 | [diff] [blame^] | 71 | self.brconfigs_aux = self.setup_ap_connection( |
| 72 | network_aux, ap=self.access_point_aux) |
Qi Jiang | 2a128de | 2018-04-27 23:00:12 -0700 | [diff] [blame] | 73 | # Set attenuator to connect the phone to main AP |
| 74 | self.log.info('Set attenuation to connect device to the main AP') |
| 75 | self.set_attenuation(self.atten_level[wc.AP_MAIN]) |
Qi Jiang | ddd0114 | 2018-10-18 22:51:42 -0700 | [diff] [blame^] | 76 | self.brconfigs_main = self.setup_ap_connection( |
| 77 | network_main, ap=self.access_point_main) |
Qi Jiang | 2a128de | 2018-04-27 23:00:12 -0700 | [diff] [blame] | 78 | self.dut.droid.goToSleepNow() |
Qi Jiang | ddd0114 | 2018-10-18 22:51:42 -0700 | [diff] [blame^] | 79 | time.sleep(5) |
Qi Jiang | 2a128de | 2018-04-27 23:00:12 -0700 | [diff] [blame] | 80 | # Trigger fastroaming |
| 81 | self.dut.log.info('Trigger fastroaming now') |
| 82 | self.set_attenuation(self.atten_level[wc.AP_AUX]) |
| 83 | self.measure_power_and_validate() |
| 84 | |
| 85 | @test_tracker_info(uuid='a0459b7c-74ce-4adb-8e55-c5365bc625eb') |
| 86 | def test_screenoff_toggle_between_AP(self): |
| 87 | |
| 88 | # Set attenuator to connect phone to both networks |
Qi Jiang | ddd0114 | 2018-10-18 22:51:42 -0700 | [diff] [blame^] | 89 | network_main = copy.deepcopy(self.main_network)[hc.BAND_2G] |
| 90 | network_aux = copy.deepcopy(self.aux_network)[hc.BAND_2G] |
Qi Jiang | 2a128de | 2018-04-27 23:00:12 -0700 | [diff] [blame] | 91 | # Connect to both APs |
| 92 | network_main = self.main_network[hc.BAND_2G] |
| 93 | network_aux = self.aux_network[hc.BAND_2G] |
Qi Jiang | ddd0114 | 2018-10-18 22:51:42 -0700 | [diff] [blame^] | 94 | self.log.info('Set attenuation to connect device to the main AP') |
| 95 | self.set_attenuation(self.atten_level[wc.AP_MAIN]) |
| 96 | self.brconfigs_main = self.setup_ap_connection( |
| 97 | network_main, ap=self.access_point_main) |
| 98 | self.log.info('Set attenuation to connect device to the aux AP') |
| 99 | self.set_attenuation(self.atten_level[wc.AP_AUX]) |
| 100 | self.brconfigs_aux = self.setup_ap_connection( |
| 101 | network_aux, ap=self.access_point_aux) |
Qi Jiang | 2a128de | 2018-04-27 23:00:12 -0700 | [diff] [blame] | 102 | self.mon_info.duration = self.toggle_interval |
| 103 | self.dut.droid.goToSleepNow() |
| 104 | time.sleep(5) |
| 105 | # Toggle between two networks |
| 106 | begin_time = utils.get_current_epoch_time() |
| 107 | for i in range(self.toggle_times): |
| 108 | self.dut.log.info('Connecting to %s' % network_main[wc.SSID]) |
| 109 | self.dut.droid.wifiConnect(network_main) |
Qi Jiang | ddd0114 | 2018-10-18 22:51:42 -0700 | [diff] [blame^] | 110 | file_path, avg_current = self.monsoon_data_collect_save() |
Qi Jiang | 2a128de | 2018-04-27 23:00:12 -0700 | [diff] [blame] | 111 | self.dut.log.info('Connecting to %s' % network_aux[wc.SSID]) |
| 112 | self.dut.droid.wifiConnect(network_aux) |
Qi Jiang | ddd0114 | 2018-10-18 22:51:42 -0700 | [diff] [blame^] | 113 | file_path, avg_current = self.monsoon_data_collect_save() |
Qi Jiang | 2a128de | 2018-04-27 23:00:12 -0700 | [diff] [blame] | 114 | [plot, dt] = wputils.monsoon_data_plot(self.mon_info, file_path) |
Qi Jiang | ddd0114 | 2018-10-18 22:51:42 -0700 | [diff] [blame^] | 115 | self.test_result = dt.source.data['y0'][0] |
Qi Jiang | 2a128de | 2018-04-27 23:00:12 -0700 | [diff] [blame] | 116 | # Take Bugreport |
| 117 | if self.bug_report: |
| 118 | self.dut.take_bug_report(self.test_name, begin_time) |
| 119 | # Path fail check |
Qi Jiang | ddd0114 | 2018-10-18 22:51:42 -0700 | [diff] [blame^] | 120 | self.pass_fail_check() |
Qi Jiang | 2a128de | 2018-04-27 23:00:12 -0700 | [diff] [blame] | 121 | |
| 122 | @test_tracker_info(uuid='e5ff95c0-b17e-425c-a903-821ba555a9b9') |
| 123 | def test_screenon_toggle_between_AP(self): |
| 124 | |
| 125 | # Set attenuator to connect phone to both networks |
Qi Jiang | ddd0114 | 2018-10-18 22:51:42 -0700 | [diff] [blame^] | 126 | network_main = copy.deepcopy(self.main_network)[hc.BAND_2G] |
| 127 | network_aux = copy.deepcopy(self.aux_network)[hc.BAND_2G] |
Qi Jiang | 2a128de | 2018-04-27 23:00:12 -0700 | [diff] [blame] | 128 | # Connect to both APs |
| 129 | network_main = self.main_network[hc.BAND_2G] |
| 130 | network_aux = self.aux_network[hc.BAND_2G] |
Qi Jiang | ddd0114 | 2018-10-18 22:51:42 -0700 | [diff] [blame^] | 131 | self.log.info('Set attenuation to connect device to the main AP') |
| 132 | self.set_attenuation(self.atten_level[wc.AP_MAIN]) |
| 133 | self.brconfigs_main = self.setup_ap_connection( |
| 134 | network_main, ap=self.access_point_main) |
| 135 | self.log.info('Set attenuation to connect device to the aux AP') |
| 136 | self.set_attenuation(self.atten_level[wc.AP_AUX]) |
| 137 | self.brconfigs_aux = self.setup_ap_connection( |
| 138 | network_aux, ap=self.access_point_aux) |
Qi Jiang | 2a128de | 2018-04-27 23:00:12 -0700 | [diff] [blame] | 139 | self.mon_info.duration = self.toggle_interval |
| 140 | time.sleep(5) |
| 141 | # Toggle between two networks |
| 142 | begin_time = utils.get_current_epoch_time() |
| 143 | for i in range(self.toggle_times): |
| 144 | self.dut.log.info('Connecting to %s' % network_main[wc.SSID]) |
| 145 | self.dut.droid.wifiConnect(network_main) |
Qi Jiang | ddd0114 | 2018-10-18 22:51:42 -0700 | [diff] [blame^] | 146 | file_path, avg_current = self.monsoon_data_collect_save() |
Qi Jiang | 2a128de | 2018-04-27 23:00:12 -0700 | [diff] [blame] | 147 | self.dut.log.info('Connecting to %s' % network_aux[wc.SSID]) |
| 148 | self.dut.droid.wifiConnect(network_aux) |
Qi Jiang | ddd0114 | 2018-10-18 22:51:42 -0700 | [diff] [blame^] | 149 | file_path, avg_current = self.monsoon_data_collect_save() |
Qi Jiang | 2a128de | 2018-04-27 23:00:12 -0700 | [diff] [blame] | 150 | [plot, dt] = wputils.monsoon_data_plot(self.mon_info, file_path) |
Qi Jiang | ddd0114 | 2018-10-18 22:51:42 -0700 | [diff] [blame^] | 151 | self.test_result = dt.source.data['y0'][0] |
Qi Jiang | 2a128de | 2018-04-27 23:00:12 -0700 | [diff] [blame] | 152 | # Take Bugreport |
| 153 | if self.bug_report: |
| 154 | self.dut.take_bug_report(self.test_name, begin_time) |
| 155 | # Path fail check |
Qi Jiang | ddd0114 | 2018-10-18 22:51:42 -0700 | [diff] [blame^] | 156 | self.pass_fail_check() |
Qi Jiang | 2a128de | 2018-04-27 23:00:12 -0700 | [diff] [blame] | 157 | |
| 158 | @test_tracker_info(uuid='a16ae337-326f-4d09-990f-42232c3c0dc4') |
| 159 | def test_screenoff_wifi_wedge(self): |
| 160 | |
| 161 | # Set attenuator to connect phone to both networks |
Qi Jiang | ddd0114 | 2018-10-18 22:51:42 -0700 | [diff] [blame^] | 162 | network_main = copy.deepcopy(self.main_network)[hc.BAND_2G] |
| 163 | network_aux = copy.deepcopy(self.aux_network)[hc.BAND_2G] |
Qi Jiang | 2a128de | 2018-04-27 23:00:12 -0700 | [diff] [blame] | 164 | # Connect to both APs |
| 165 | network_main = self.main_network[hc.BAND_2G] |
| 166 | network_aux = self.aux_network[hc.BAND_2G] |
Qi Jiang | ddd0114 | 2018-10-18 22:51:42 -0700 | [diff] [blame^] | 167 | self.log.info('Set attenuation to connect device to the main AP') |
| 168 | self.set_attenuation(self.atten_level[wc.AP_MAIN]) |
| 169 | self.brconfigs_main = self.setup_ap_connection( |
| 170 | network_main, ap=self.access_point_main) |
| 171 | self.log.info('Set attenuation to connect device to the aux AP') |
| 172 | self.set_attenuation(self.atten_level[wc.AP_AUX]) |
| 173 | self.brconfigs_aux = self.setup_ap_connection( |
| 174 | network_aux, ap=self.access_point_aux) |
Qi Jiang | 2a128de | 2018-04-27 23:00:12 -0700 | [diff] [blame] | 175 | self.log.info('Forget network {}'.format(network_aux[wc.SSID])) |
| 176 | wutils.wifi_forget_network(self.dut, network_aux[wc.SSID]) |
| 177 | self.log.info('Set attenuation to trigger wedge condition') |
| 178 | self.set_attenuation(self.atten_level[self.current_test_name]) |
| 179 | self.dut.droid.goToSleepNow() |
| 180 | self.measure_power_and_validate() |