1# Copyright (C) 2023 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15 16import sys 17import logging 18import pprint 19 20 21from bluetooth_test import bluetooth_base_test 22from mobly import asserts 23from mobly import test_runner 24from mobly.controllers import android_device 25 26from mbs_utils import constants 27from mbs_utils import spectatio_utils 28from mbs_utils import bt_utils 29 30 31class BluetoothPalette(bluetooth_base_test.BluetoothBaseTest): 32 """Enable and Disable Bluetooth from Bluetooth Palette.""" 33 34 def setup_test(self): 35 """Setup steps before any test is executed.""" 36 # Pair the devices 37 self.bt_utils.pair_primary_to_secondary(); 38 39 def test_enable_disable_bluetooth_button(self): 40 """Tests enable and disable functionality of bluetooth.""" 41 self.call_utils.open_bluetooth_palette() 42 self.call_utils.wait_with_log( 43 constants.DEFAULT_WAIT_TIME_FIVE_SECS 44 ) 45 asserts.assert_true(self.call_utils.is_bluetooth_connected(),'Bluetooth Connected') 46 self.call_utils.click_bluetooth_button() 47 self.call_utils.wait_with_log( 48 constants.DEFAULT_WAIT_TIME_FIVE_SECS 49 ) 50 asserts.assert_false(self.call_utils.is_bluetooth_connected(),'Bluetooth Disconnected') 51 52 53 54if __name__ == '__main__': 55 # Pass test arguments after '--' to the test runner. 56 # Needed for Mobly Test Runner 57 if '--' in sys.argv: 58 index = sys.argv.index('--') 59 sys.argv = sys.argv[:1] + sys.argv[index + 1:] 60 test_runner.main() 61