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"""Test of Enable-Disable Bluetooth Audio via Music button
16
17Steps to reproduce:
18
19Launch Bluetooth Audio from All apps
20     1. Launch Bluetooth Palette from Action Bar
21     2. Tap Enabled- Blue  Music button - it will turn to be grey - disabled
22     3. Launch All Apps- Bluetooth Audio app - Verify: 'Connect to Bluetooth' message will be displayed in Bluetooth Audio page
23     4. Turn On Music button in Bluetooth Palette - Launch Bluetooth Audio  Verify media source and song metadata from currently played song should be displayed in Media page
24     5. Repeat Turning Off/On Media button several times
25"""
26
27from bluetooth_test import bluetooth_base_test
28from mobly import asserts
29
30from utilities import constants
31from utilities.main_utils import common_main
32
33class EnableDisableBluetoothAudioViaMusicButton(bluetooth_base_test.BluetoothBaseTest):
34  """Enable and Disable Bluetooth Audio Bluetooth Palette."""
35
36  def setup_test(self):
37    """Setup steps before any test is executed."""
38    # Pair caller phone with automotive device
39    self.bt_utils.pair_primary_to_secondary()
40
41  def test_enable_disable_bluetooth_audio_via_music_button(self):
42    """ Enable - Disable Bluetooth Audio via music button"""
43    self.call_utils.open_bluetooth_palette()
44    self.call_utils.wait_with_log(10)
45    asserts.assert_true(self.call_utils.is_bluetooth_media_button_enabled(),'Media Button is Not Enabled')
46    self.call_utils.click_on_bluetooth_palette_media_button()
47    asserts.assert_false(self.call_utils.is_bluetooth_media_button_enabled(),'Media Button is Not disabled')
48    self.call_utils.open_bluetooth_media_app()
49    self.call_utils.click_cancel_label_visible_on_bluetooth_audio_page()
50    asserts.assert_true(self.call_utils.is_connect_to_bluetooth_label_visible_on_bluetooth_audio_page(), "Connect to Bluetooth Label is not visible")
51    self.call_utils.open_bluetooth_palette()
52    self.call_utils.click_on_bluetooth_palette_media_button()
53    asserts.assert_true(self.call_utils.is_bluetooth_media_button_enabled(),'Media Button is Not Enabled')
54    self.call_utils.open_bluetooth_media_app()
55    asserts.assert_false(self.call_utils.is_connect_to_bluetooth_label_visible_on_bluetooth_audio_page(), "Connect to Bluetooth Label is visible")
56
57
58if __name__ == '__main__':
59  common_main()