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 17import time 18from acts.test_decorators import test_tracker_info 19from acts.test_utils.power import PowerWiFiBaseTest as PWBT 20from acts.test_utils.wifi import wifi_power_test_utils as wputils 21 22 23class PowerWiFidtimTest(PWBT.PowerWiFiBaseTest): 24 def dtim_test_func(self, dtim_max=10): 25 """A reusable function for DTIM test. 26 Covering different DTIM value, with screen ON or OFF and 2g/5g network 27 28 Args: 29 dtim: the value for DTIM set on the phone 30 screen_status: screen on or off 31 network: a dict of information for the network to connect 32 """ 33 attrs = ['screen_status', 'wifi_band', 'dtim'] 34 indices = [2, 4, 6] 35 self.decode_test_configs(attrs, indices) 36 # Initialize the dut to rock-bottom state 37 rebooted = wputils.change_dtim( 38 self.dut, 39 gEnableModulatedDTIM=int(self.test_configs.dtim), 40 gMaxLIModulatedDTIM=dtim_max) 41 if rebooted: 42 self.dut_rockbottom() 43 self.dut.log.info('DTIM value of the phone is now {}'.format( 44 self.test_configs.dtim)) 45 self.setup_ap_connection( 46 self.main_network[self.test_configs.wifi_band]) 47 if self.test_configs.screen_status == 'OFF': 48 self.dut.droid.goToSleepNow() 49 self.dut.log.info('Screen is OFF') 50 time.sleep(5) 51 self.measure_power_and_validate() 52 53 # Test cases 54 @test_tracker_info(uuid='b6c4114d-984a-4269-9e77-2bec0e4b6e6f') 55 def test_screen_OFF_band_2g_dtim_2(self): 56 self.dtim_test_func() 57 58 @test_tracker_info(uuid='384d3b0f-4335-4b00-8363-308ec27a150c') 59 def test_screen_ON_band_2g_dtim_1(self): 60 self.dtim_test_func() 61 62 @test_tracker_info(uuid='017f57c3-e133-461d-80be-d025d1491d8a') 63 def test_screen_OFF_band_5g_dtim_2(self): 64 self.dtim_test_func() 65 66 @test_tracker_info(uuid='327af44d-d9e7-49e0-9bda-accad6241dc7') 67 def test_screen_ON_band_5g_dtim_1(self): 68 self.dtim_test_func() 69