blob: b5ffc5e6b95fee3151d20837d1742ab2b3d7f6fb [file] [log] [blame]
#!/usr/bin/env python3.4
#
# Copyright 2017 - The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
import os
import time
from acts import base_test
from acts.controllers.ap_lib import hostapd_constants as hc
from acts.test_decorators import test_tracker_info
from acts.test_utils.wifi import wifi_test_utils as wutils
from acts.test_utils.wifi import wifi_power_test_utils as wputils
class PowerdtimTest(base_test.BaseTestClass):
def __init__(self, controllers):
base_test.BaseTestClass.__init__(self, controllers)
self.tests = ("test_2g_screenoff_dtimx1", "test_2g_screenoff_dtimx2",
"test_2g_screenoff_dtimx4", "test_2g_screenoff_dtimx9",
"test_2g_screenon_dtimx1", "test_2g_screenon_dtimx2",
"test_2g_screenon_dtimx4", "test_2g_screenon_dtimx9",
"test_5g_screenoff_dtimx1", "test_5g_screenoff_dtimx2",
"test_5g_screenoff_dtimx4", "test_5g_screenoff_dtimx9",
"test_5g_screenon_dtimx1", "test_5g_screenon_dtimx2",
"test_5g_screenon_dtimx4", "test_5g_screenon_dtimx9")
def setup_class(self):
self.log = logging.getLogger()
self.dut = self.android_devices[0]
self.access_point = self.access_points[0]
req_params = ["main_network", "aux_network", "dtimtest_params"]
self.unpack_userparams(req_params)
self.unpack_testparams(self.dtimtest_params)
self.mon_data_path = os.path.join(self.log_path, "Monsoon")
self.mon = self.monsoons[0]
self.mon.set_voltage(4.2)
self.mon.set_max_current(8.0)
self.mon.attach_device(self.dut)
self.mon_info = {
"dut": self.mon,
"freq": self.mon_freq,
"duration": self.mon_duration,
"offset": self.mon_offset,
"data_path": self.mon_data_path
}
self.num_atten = self.attenuators[0].instrument.num_atten
def teardown_class(self):
self.mon.usb("on")
def unpack_testparams(self, bulk_params):
"""Unpack all the test specific parameters.
Args:
bulk_params: dict with all test specific params in the config file
"""
for key in bulk_params.keys():
setattr(self, key, bulk_params[key])
def dtim_test_func(self, dtim, screen_status, network, dtim_max=6):
"""A reusable function for DTIM test.
Covering different DTIM value, with screen ON or OFF and 2g/5g network
Args:
dtim: the value for DTIM set on the phone
screen_status: screen on or off
network: a dict of information for the network to connect
"""
# Initialize the dut to rock-bottom state
wputils.change_dtim(
self.dut, gEnableModulatedDTIM=dtim, gMaxLIModulatedDTIM=dtim_max)
self.dut.log.info('DTIM value of the phone is now {}'.format(dtim))
wputils.dut_rockbottom(self.dut)
wutils.wifi_toggle_state(self.dut, True)
[
self.attenuators[i].set_atten(self.atten_level['main_AP'][i])
for i in range(self.num_atten)
]
self.log.info("Set attenuation level to connect the main AP")
wputils.ap_setup(self.access_point, network)
wutils.wifi_connect(self.dut, network)
if screen_status == "OFF":
self.dut.droid.goToSleepNow()
self.dut.log.info("Screen is OFF")
time.sleep(5)
# Collect power data and plot
file_path, avg_current = wputils.monsoon_data_collect_save(
self.dut, self.mon_info, self.current_test_name, self.bug_report)
wputils.monsoon_data_plot(self.mon_info, file_path)
wputils.pass_fail_check(self, avg_current)
# Test cases
@test_tracker_info(uuid="2a70a78b-93a8-46a6-a829-e1624b8239d2")
def test_2g_screenoff_dtimx1(self):
network = self.main_network[hc.BAND_2G]
self.dtim_test_func(1, "OFF", network)
@test_tracker_info(uuid="b6c4114d-984a-4269-9e77-2bec0e4b6e6f")
def test_2g_screenoff_dtimx2(self):
network = self.main_network[hc.BAND_2G]
self.dtim_test_func(2, "OFF", network)
@test_tracker_info(uuid="2ae5bc29-3d5f-4fbb-9ff6-f5bd499a9d6e")
def test_2g_screenoff_dtimx4(self):
network = self.main_network[hc.BAND_2G]
self.dtim_test_func(4, "OFF", network)
@test_tracker_info(uuid="b37fa75f-6166-4247-b15c-adcda8c7038e")
def test_2g_screenoff_dtimx9(self):
network = self.main_network[hc.BAND_2G]
self.dtim_test_func(9, "OFF", network, dtim_max=10)
@test_tracker_info(uuid="384d3b0f-4335-4b00-8363-308ec27a150c")
def test_2g_screenon_dtimx1(self):
network = self.main_network[hc.BAND_2G]
self.dtim_test_func(1, "ON", network)
@test_tracker_info(uuid="dee62525-7c7a-4a3c-97c2-db6b272fb8b2")
def test_2g_screenon_dtimx2(self):
network = self.main_network[hc.BAND_2G]
self.dtim_test_func(2, "ON", network)
@test_tracker_info(uuid="79d0f065-2c46-4400-b02c-5ad60e79afea")
def test_2g_screenon_dtimx4(self):
network = self.main_network[hc.BAND_2G]
self.dtim_test_func(4, "ON", network)
@test_tracker_info(uuid="50bda9c9-b443-4f0e-b4a6-cdc4483084b7")
def test_2g_screenon_dtimx9(self):
network = self.main_network[hc.BAND_2G]
self.dtim_test_func(9, "ON", network, dtim_max=10)
@test_tracker_info(uuid="5e2f73cb-7e4e-4a25-8fd5-c85adfdf466e")
def test_5g_screenoff_dtimx1(self):
network = self.main_network[hc.BAND_5G]
self.dtim_test_func(1, "OFF", network)
@test_tracker_info(uuid="017f57c3-e133-461d-80be-d025d1491d8a")
def test_5g_screenoff_dtimx2(self):
network = self.main_network[hc.BAND_5G]
self.dtim_test_func(2, "OFF", network)
@test_tracker_info(uuid="b84a1cb3-9573-4bfd-9875-0f33cb171cc5")
def test_5g_screenoff_dtimx4(self):
network = self.main_network[hc.BAND_5G]
self.dtim_test_func(4, "OFF", network)
@test_tracker_info(uuid="75644df4-2cc8-4bbd-8985-0656a4f9d056")
def test_5g_screenoff_dtimx9(self):
network = self.main_network[hc.BAND_5G]
self.dtim_test_func(9, "OFF", network, dtim_max=10)
@test_tracker_info(uuid="327af44d-d9e7-49e0-9bda-accad6241dc7")
def test_5g_screenon_dtimx1(self):
network = self.main_network[hc.BAND_5G]
self.dtim_test_func(1, "ON", network)
@test_tracker_info(uuid="96c7a28d-9d7d-404f-bd9f-3661b5a4b4c9")
def test_5g_screenon_dtimx2(self):
network = self.main_network[hc.BAND_5G]
self.dtim_test_func(2, "ON", network)
@test_tracker_info(uuid="8b32585f-2517-426b-a2c9-8087093cf991")
def test_5g_screenon_dtimx4(self):
network = self.main_network[hc.BAND_5G]
self.dtim_test_func(4, "ON", network)
@test_tracker_info(uuid="17a35bfe-f0a4-41cf-822a-f727a8b8090f")
def test_5g_screenon_dtimx9(self):
network = self.main_network[hc.BAND_5G]
self.dtim_test_func(9, "ON", network, dtim_max=10)