blob: 3a03223ebde983b6e0daa6c189db33eed59c56a6 [file] [log] [blame]
Qi Jiang2a128de2018-04-27 23:00:12 -07001#!/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 Jiangddd01142018-10-18 22:51:42 -070017import copy
Qi Jiang2a128de2018-04-27 23:00:12 -070018import time
19from acts import utils
20from acts.controllers.ap_lib import hostapd_constants as hc
21from acts.test_decorators import test_tracker_info
22from acts.test_utils.power import PowerWiFiBaseTest as PWBT
23from acts.test_utils.wifi import wifi_constants as wc
24from acts.test_utils.wifi import wifi_test_utils as wutils
25from acts.test_utils.wifi import wifi_power_test_utils as wputils
26
27
28class PowerWiFiroamingTest(PWBT.PowerWiFiBaseTest):
Qi Jiangddd01142018-10-18 22:51:42 -070029 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 Jiang2a128de2018-04-27 23:00:12 -070034
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 Jiang2a128de2018-04-27 23:00:12 -070042 # Setup both APs
Qi Jiangddd01142018-10-18 22:51:42 -070043 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 Jiang2a128de2018-04-27 23:00:12 -070053 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 Jiangddd01142018-10-18 22:51:42 -070064 network_main = copy.deepcopy(self.main_network)[hc.BAND_2G]
65 network_aux = copy.deepcopy(self.aux_network)[hc.BAND_2G]
Qi Jiang2a128de2018-04-27 23:00:12 -070066 # 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 Jiangddd01142018-10-18 22:51:42 -070071 self.brconfigs_aux = self.setup_ap_connection(
72 network_aux, ap=self.access_point_aux)
Qi Jiang2a128de2018-04-27 23:00:12 -070073 # 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 Jiangddd01142018-10-18 22:51:42 -070076 self.brconfigs_main = self.setup_ap_connection(
77 network_main, ap=self.access_point_main)
Qi Jiang2a128de2018-04-27 23:00:12 -070078 self.dut.droid.goToSleepNow()
Qi Jiangddd01142018-10-18 22:51:42 -070079 time.sleep(5)
Qi Jiang2a128de2018-04-27 23:00:12 -070080 # 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 Jiangddd01142018-10-18 22:51:42 -070089 network_main = copy.deepcopy(self.main_network)[hc.BAND_2G]
90 network_aux = copy.deepcopy(self.aux_network)[hc.BAND_2G]
Qi Jiang2a128de2018-04-27 23:00:12 -070091 # Connect to both APs
92 network_main = self.main_network[hc.BAND_2G]
93 network_aux = self.aux_network[hc.BAND_2G]
Qi Jiangddd01142018-10-18 22:51:42 -070094 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 Jiang2a128de2018-04-27 23:00:12 -0700102 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 Jiangddd01142018-10-18 22:51:42 -0700110 file_path, avg_current = self.monsoon_data_collect_save()
Qi Jiang2a128de2018-04-27 23:00:12 -0700111 self.dut.log.info('Connecting to %s' % network_aux[wc.SSID])
112 self.dut.droid.wifiConnect(network_aux)
Qi Jiangddd01142018-10-18 22:51:42 -0700113 file_path, avg_current = self.monsoon_data_collect_save()
Qi Jiang2a128de2018-04-27 23:00:12 -0700114 [plot, dt] = wputils.monsoon_data_plot(self.mon_info, file_path)
Qi Jiangddd01142018-10-18 22:51:42 -0700115 self.test_result = dt.source.data['y0'][0]
Qi Jiang2a128de2018-04-27 23:00:12 -0700116 # Take Bugreport
117 if self.bug_report:
118 self.dut.take_bug_report(self.test_name, begin_time)
119 # Path fail check
Qi Jiangddd01142018-10-18 22:51:42 -0700120 self.pass_fail_check()
Qi Jiang2a128de2018-04-27 23:00:12 -0700121
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 Jiangddd01142018-10-18 22:51:42 -0700126 network_main = copy.deepcopy(self.main_network)[hc.BAND_2G]
127 network_aux = copy.deepcopy(self.aux_network)[hc.BAND_2G]
Qi Jiang2a128de2018-04-27 23:00:12 -0700128 # Connect to both APs
129 network_main = self.main_network[hc.BAND_2G]
130 network_aux = self.aux_network[hc.BAND_2G]
Qi Jiangddd01142018-10-18 22:51:42 -0700131 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 Jiang2a128de2018-04-27 23:00:12 -0700139 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 Jiangddd01142018-10-18 22:51:42 -0700146 file_path, avg_current = self.monsoon_data_collect_save()
Qi Jiang2a128de2018-04-27 23:00:12 -0700147 self.dut.log.info('Connecting to %s' % network_aux[wc.SSID])
148 self.dut.droid.wifiConnect(network_aux)
Qi Jiangddd01142018-10-18 22:51:42 -0700149 file_path, avg_current = self.monsoon_data_collect_save()
Qi Jiang2a128de2018-04-27 23:00:12 -0700150 [plot, dt] = wputils.monsoon_data_plot(self.mon_info, file_path)
Qi Jiangddd01142018-10-18 22:51:42 -0700151 self.test_result = dt.source.data['y0'][0]
Qi Jiang2a128de2018-04-27 23:00:12 -0700152 # Take Bugreport
153 if self.bug_report:
154 self.dut.take_bug_report(self.test_name, begin_time)
155 # Path fail check
Qi Jiangddd01142018-10-18 22:51:42 -0700156 self.pass_fail_check()
Qi Jiang2a128de2018-04-27 23:00:12 -0700157
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 Jiangddd01142018-10-18 22:51:42 -0700162 network_main = copy.deepcopy(self.main_network)[hc.BAND_2G]
163 network_aux = copy.deepcopy(self.aux_network)[hc.BAND_2G]
Qi Jiang2a128de2018-04-27 23:00:12 -0700164 # Connect to both APs
165 network_main = self.main_network[hc.BAND_2G]
166 network_aux = self.aux_network[hc.BAND_2G]
Qi Jiangddd01142018-10-18 22:51:42 -0700167 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 Jiang2a128de2018-04-27 23:00:12 -0700175 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()