• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""
2  Copyright (C) 2023 The Android Open Source Project
3
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7
8       http://www.apache.org/licenses/LICENSE-2.0
9
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15
16
17
18  Test Steps:
19  (0. Flash device)
20  1. Verify by default BT should be ON always
21  2. BluetoothManagerService: Startup: Bluetooth persisted state is ON
22
23"""
24
25import sys
26import logging
27import pprint
28
29from mobly import asserts
30from mobly import base_test
31from mobly import test_runner
32from mobly.controllers import android_device
33
34from mbs_utils import constants
35from mbs_utils import spectatio_utils
36from mbs_utils import bt_utils
37
38
39class BluetoothDefaultStateTest(base_test.BaseTestClass):
40
41    def setup_class(self):
42        # Registering android_device controller module, and declaring that the test
43        # requires at least two Android devices.
44        self.ads = self.register_controller(android_device, min_number=2)
45
46        # Even in a default state test, tags should be set to make debugging easier.
47        self.discoverer = android_device.get_device(
48            self.ads, label='auto')
49        self.discoverer.debug_tag = 'discoverer'
50        self.discoverer.load_snippet('mbs', android_device.MBS_PACKAGE)
51
52
53    def setup_test(self):
54        # Default state test requires no setup.
55        pass
56
57    def test_device_connectivity_in_level_two(self):
58        # Confirm that the bluetooth state is ON
59        asserts.assert_true(
60            self.discoverer.mbs.btIsEnabled(),
61            "Expected bluetooth to be enabled by default, but it was not.")
62
63    def teardown_test(self):
64        # Default state test should still disable bluetooth after checking default state.
65        self.discoverer.mbs.btDisable()
66
67
68
69if __name__ == '__main__':
70    # Take test args
71    test_runner.main()