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 17from acts import base_test 18from acts.test_decorators import test_tracker_info 19import acts.test_utils.power.PowerBTBaseTest as PBtBT 20 21 22class PowerBTbaselineTest(PBtBT.PowerBTBaseTest): 23 def __init__(self, controllers): 24 25 base_test.BaseTestClass.__init__(self, controllers) 26 27 def bt_baseline_test_func(self): 28 """Base function for BT baseline measurement. 29 30 Steps: 31 1. Sets the phone in airplane mode, disables gestures and location 32 2. Turns ON/OFF BT, BLE and screen according to test conditions 33 3. Measures the power consumption 34 4. Asserts pass/fail criteria based on measured power 35 """ 36 37 # Decode the test params from test name 38 attrs = ['screen_status', 'bt_status', 'ble_status', 'scan_status'] 39 indices = [2, 4, 6, 7] 40 self.decode_test_configs(attrs, indices) 41 # Setup the phoen at desired state 42 self.phone_setup_for_BT(self.test_configs.bt_status, 43 self.test_configs.ble_status, 44 self.test_configs.screen_status) 45 if self.test_configs.scan_status == 'connectable': 46 self.dut.droid.bluetoothMakeConnectable() 47 elif self.test_configs.scan_status == 'discoverable': 48 self.dut.droid.bluetoothMakeDiscoverable( 49 self.mon_info.duration + self.mon_info.offset) 50 self.measure_power_and_validate() 51 52 # Test cases- Baseline 53 @test_tracker_info(uuid='3f8ac0cb-f20d-4569-a58e-6009c89ea049') 54 def test_screen_OFF_bt_ON_ble_ON_connectable(self): 55 self.bt_baseline_test_func() 56 57 @test_tracker_info(uuid='d54a992e-37ed-460a-ada7-2c51941557fd') 58 def test_screen_OFF_bt_ON_ble_ON_discoverable(self): 59 self.bt_baseline_test_func() 60 61 @test_tracker_info(uuid='8f4c36b5-b18e-4aa5-9fe5-aafb729c1034') 62 def test_screen_ON_bt_ON_ble_ON_connectable(self): 63 self.bt_baseline_test_func() 64 65 @test_tracker_info(uuid='7128356f-67d8-46b3-9d6b-1a4c9a7a1745') 66 def test_screen_ON_bt_ON_ble_ON_discoverable(self): 67 self.bt_baseline_test_func() 68