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='2a70a78b-93a8-46a6-a829-e1624b8239d2') 55 def test_screen_OFF_band_2g_dtim_1(self): 56 self.dtim_test_func() 57 58 @test_tracker_info(uuid='b6c4114d-984a-4269-9e77-2bec0e4b6e6f') 59 def test_screen_OFF_band_2g_dtim_2(self): 60 self.dtim_test_func() 61 62 @test_tracker_info(uuid='2ae5bc29-3d5f-4fbb-9ff6-f5bd499a9d6e') 63 def test_screen_OFF_band_2g_dtim_4(self): 64 self.dtim_test_func() 65 66 @test_tracker_info(uuid='b37fa75f-6166-4247-b15c-adcda8c7038e') 67 def test_screen_OFF_band_2g_dtim_5(self): 68 self.dtim_test_func() 69 70 @test_tracker_info(uuid='384d3b0f-4335-4b00-8363-308ec27a150c') 71 def test_screen_ON_band_2g_dtim_1(self): 72 self.dtim_test_func() 73 74 @test_tracker_info(uuid='79d0f065-2c46-4400-b02c-5ad60e79afea') 75 def test_screen_ON_band_2g_dtim_4(self): 76 self.dtim_test_func() 77 78 @test_tracker_info(uuid='5e2f73cb-7e4e-4a25-8fd5-c85adfdf466e') 79 def test_screen_OFF_band_5g_dtim_1(self): 80 self.dtim_test_func() 81 82 @test_tracker_info(uuid='017f57c3-e133-461d-80be-d025d1491d8a') 83 def test_screen_OFF_band_5g_dtim_2(self): 84 self.dtim_test_func() 85 86 @test_tracker_info(uuid='b84a1cb3-9573-4bfd-9875-0f33cb171cc5') 87 def test_screen_OFF_band_5g_dtim_4(self): 88 self.dtim_test_func() 89 90 @test_tracker_info(uuid='75644df4-2cc8-4bbd-8985-0656a4f9d056') 91 def test_screen_OFF_band_5g_dtim_5(self): 92 self.dtim_test_func() 93 94 @test_tracker_info(uuid='327af44d-d9e7-49e0-9bda-accad6241dc7') 95 def test_screen_ON_band_5g_dtim_1(self): 96 self.dtim_test_func() 97 98 @test_tracker_info(uuid='8b32585f-2517-426b-a2c9-8087093cf991') 99 def test_screen_ON_band_5g_dtim_4(self): 100 self.dtim_test_func() 101