Home | History | Annotate | Download | only in wifi
      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 
     17 import time
     18 from acts import utils
     19 from acts.controllers.ap_lib import hostapd_constants as hc
     20 from acts.test_decorators import test_tracker_info
     21 from acts.test_utils.power import PowerWiFiBaseTest as PWBT
     22 from acts.test_utils.wifi import wifi_constants as wc
     23 from acts.test_utils.wifi import wifi_test_utils as wutils
     24 from acts.test_utils.wifi import wifi_power_test_utils as wputils
     25 
     26 
     27 class PowerWiFiroamingTest(PWBT.PowerWiFiBaseTest):
     28 
     29     # Test cases
     30     @test_tracker_info(uuid='392622d3-0c5c-4767-afa2-abfb2058b0b8')
     31     def test_screenoff_roaming(self):
     32         """Test roaming power consumption with screen off.
     33         Change the attenuation level to trigger roaming between two APs
     34 
     35         """
     36         self.log.info('Set attenuation to connect device to both APs')
     37         self.set_attenuation(self.atten_level['zero_atten'])
     38         # Setup both APs
     39         network_main = self.main_network[hc.BAND_2G]
     40         network_aux = self.aux_network[hc.BAND_2G]
     41         self.brconfigs_aux = self.setup_ap_connection(network_aux)
     42         self.brconfigs_main = self.setup_ap_connection(network_main)
     43         self.dut.droid.goToSleepNow()
     44         time.sleep(5)
     45         # Set attenuator to trigger roaming
     46         self.dut.log.info('Trigger roaming now')
     47         self.set_attenuation(self.atten_level[self.current_test_name])
     48         self.measure_power_and_validate()
     49 
     50     @test_tracker_info(uuid='2fec5208-043a-410a-8fd2-6784d70a3587')
     51     def test_screenoff_fastroaming(self):
     52 
     53         # Setup the aux AP
     54         network_main = self.main_network[hc.BAND_2G]
     55         network_aux = self.aux_network[hc.BAND_2G]
     56         # Set the same SSID for the AUX AP for fastroaming purpose
     57         network_aux[wc.SSID] = network_main[wc.SSID]
     58         # Set attenuator to connect the phone to the aux AP
     59         self.log.info('Set attenuation to connect device to the aux AP')
     60         self.set_attenuation(self.atten_level[wc.AP_AUX])
     61         self.brconfigs_aux = self.setup_ap_connection(network_aux)
     62         # Set attenuator to connect the phone to main AP
     63         self.log.info('Set attenuation to connect device to the main AP')
     64         self.set_attenuation(self.atten_level[wc.AP_MAIN])
     65         self.brconfigs_main = self.setup_ap_connection(network_main)
     66         time.sleep(5)
     67         self.dut.droid.goToSleepNow()
     68         # Trigger fastroaming
     69         self.dut.log.info('Trigger fastroaming now')
     70         self.set_attenuation(self.atten_level[wc.AP_AUX])
     71         self.measure_power_and_validate()
     72 
     73     @test_tracker_info(uuid='a0459b7c-74ce-4adb-8e55-c5365bc625eb')
     74     def test_screenoff_toggle_between_AP(self):
     75 
     76         # Set attenuator to connect phone to both networks
     77         self.log.info('Set attenuation to connect device to both APs')
     78         self.set_attenuation(self.atten_level[self.current_test_name])
     79         # Connect to both APs
     80         network_main = self.main_network[hc.BAND_2G]
     81         network_aux = self.aux_network[hc.BAND_2G]
     82         self.brconfigs_main = self.setup_ap_connection(network_main)
     83         self.brconfigs_aux = self.setup_ap_connection(network_aux)
     84         self.mon_info.duration = self.toggle_interval
     85         self.dut.droid.goToSleepNow()
     86         time.sleep(5)
     87         # Toggle between two networks
     88         begin_time = utils.get_current_epoch_time()
     89         for i in range(self.toggle_times):
     90             self.dut.log.info('Connecting to %s' % network_main[wc.SSID])
     91             self.dut.droid.wifiConnect(network_main)
     92             file_path, avg_current = wputils.monsoon_data_collect_save(
     93                 self.dut, self.mon_info, self.current_test_name)
     94             self.dut.log.info('Connecting to %s' % network_aux[wc.SSID])
     95             self.dut.droid.wifiConnect(network_aux)
     96             file_path, avg_current = wputils.monsoon_data_collect_save(
     97                 self.dut, self.mon_info, self.current_test_name)
     98         [plot, dt] = wputils.monsoon_data_plot(self.mon_info, file_path)
     99         avg_current = dt.source.data['y0'][0]
    100         # Take Bugreport
    101         if self.bug_report:
    102             self.dut.take_bug_report(self.test_name, begin_time)
    103         # Path fail check
    104         wputils.pass_fail_check(self, avg_current)
    105 
    106     @test_tracker_info(uuid='e5ff95c0-b17e-425c-a903-821ba555a9b9')
    107     def test_screenon_toggle_between_AP(self):
    108 
    109         # Set attenuator to connect phone to both networks
    110         self.log.info('Set attenuation to connect device to both APs')
    111         self.set_attenuation(self.atten_level[self.current_test_name])
    112         # Connect to both APs
    113         network_main = self.main_network[hc.BAND_2G]
    114         network_aux = self.aux_network[hc.BAND_2G]
    115         self.brconfigs_main = self.setup_ap_connection(network_main)
    116         self.brconfigs_aux = self.setup_ap_connection(network_aux)
    117         self.mon_info.duration = self.toggle_interval
    118         time.sleep(5)
    119         # Toggle between two networks
    120         begin_time = utils.get_current_epoch_time()
    121         for i in range(self.toggle_times):
    122             self.dut.log.info('Connecting to %s' % network_main[wc.SSID])
    123             self.dut.droid.wifiConnect(network_main)
    124             file_path, avg_current = wputils.monsoon_data_collect_save(
    125                 self.dut, self.mon_info, self.current_test_name)
    126             self.dut.log.info('Connecting to %s' % network_aux[wc.SSID])
    127             self.dut.droid.wifiConnect(network_aux)
    128             file_path, avg_current = wputils.monsoon_data_collect_save(
    129                 self.dut, self.mon_info, self.current_test_name)
    130         [plot, dt] = wputils.monsoon_data_plot(self.mon_info, file_path)
    131         avg_current = dt.source.data['y0'][0]
    132         # Take Bugreport
    133         if self.bug_report:
    134             self.dut.take_bug_report(self.test_name, begin_time)
    135         # Path fail check
    136         wputils.pass_fail_check(self, avg_current)
    137 
    138     @test_tracker_info(uuid='a16ae337-326f-4d09-990f-42232c3c0dc4')
    139     def test_screenoff_wifi_wedge(self):
    140 
    141         # Set attenuator to connect phone to both networks
    142         self.log.info('Set attenuation to connect device to both APs')
    143         self.set_attenuation(self.atten_level['zero_atten'])
    144         # Connect to both APs
    145         network_main = self.main_network[hc.BAND_2G]
    146         network_aux = self.aux_network[hc.BAND_2G]
    147         self.brconfigs_main = self.setup_ap_connection(network_main)
    148         self.brconfigs_aux = self.setup_ap_connection(network_aux)
    149         self.log.info('Forget network {}'.format(network_aux[wc.SSID]))
    150         wutils.wifi_forget_network(self.dut, network_aux[wc.SSID])
    151         self.log.info('Set attenuation to trigger wedge condition')
    152         self.set_attenuation(self.atten_level[self.current_test_name])
    153         self.dut.droid.goToSleepNow()
    154         self.measure_power_and_validate()
    155