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
15from mobly import asserts
16from bluetooth_test import bluetooth_base_test
17
18from utilities.main_utils import common_main
19
20class DisableEnableHFPBluetoothProfile(bluetooth_base_test.BluetoothBaseTest):
21  """Enable and Disable Bluetooth from Bluetooth Palette."""
22
23  def setup_test(self):
24    """Setup steps before any test is executed."""
25    # Pair caller phone with automotive device
26    self.call_utils.press_home()
27    self.bt_utils.pair_primary_to_secondary()
28
29  def test_disable_enable_phone_hfp_bluetooth_profile(self):
30    """Disable - Enable Phone-HFP Bluetooth profile"""
31    self.call_utils.open_bluetooth_palette()
32    self.call_utils.wait_with_log(10)
33    self.call_utils.click_phone_button()
34    self.call_utils.wait_with_log(10)
35    asserts.assert_false(self.call_utils.verify_disabled_phone_profile(),'Phone is disabled')
36    self.call_utils.open_phone_app()
37    asserts.assert_true(self.call_utils.verify_bluetooth_hfp_error_displayed(),'Bluetooth hfp error is displayed')
38    self.call_utils.open_bluetooth_palette()
39    self.call_utils.wait_with_log(5)
40    self.call_utils.click_phone_button()
41    self.call_utils.wait_with_log(5)
42    self.call_utils.open_phone_app()
43    asserts.assert_true(self.call_utils.verify_dialer_recents_tab(),'Dialer recents tab is displayed')
44    asserts.assert_true(self.call_utils.verify_dialer_contacts_tab(),'Dialer contacts tab is displayed')
45    asserts.assert_true(self.call_utils.verify_dialer_favorites_tab(),'Dialer favorites tab is displayed')
46    asserts.assert_true(self.call_utils.verify_dialer_dialpad_tab(),'Dialer dialpad tab is displayed')
47
48  def teardown_test(self):
49    self.call_utils.press_home()
50    super().teardown_test()
51
52
53if __name__ == '__main__':
54  common_main()