xref: /aosp_15_r20/platform_testing/tests/automotive/mobly_tests/media/media_test_playlist_rendering.py (revision dd0948b35e70be4c0246aabd6c72554a5eb8b22a)
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
15import logging
16
17from bluetooth_test import bluetooth_base_test
18from mobly import asserts
19from utilities.media_utils import MediaUtils
20from utilities.common_utils import CommonUtils
21from utilities.main_utils import common_main
22
23class PlaylistRendering(bluetooth_base_test.BluetoothBaseTest):
24
25    def setup_class(self):
26        super().setup_class()
27        self.media_utils = MediaUtils(self.target, self.discoverer)
28        self.common_utils = CommonUtils(self.target, self.discoverer)
29
30    def setup_test(self):
31        self.common_utils.grant_local_mac_address_permission()
32
33        self.common_utils.enable_wifi_on_phone_device()
34        self.bt_utils.pair_primary_to_secondary()
35        super().enable_recording()
36        self.media_utils.enable_bt_media_debugging_logs()
37
38    def test_playlist_rendering(self):
39        """Tests validating is song selectable using playlist on HU"""
40        self.media_utils.open_media_app_on_hu()
41        self.media_utils.open_youtube_music_app()
42        self.call_utils.wait_with_log(5)
43        self.call_utils.handle_bluetooth_audio_pop_up()
44        logging.info("Getting song title from phone device: %s", self.media_utils.get_song_title_from_phone())
45        self.media_utils.maximize_now_playing()
46        asserts.assert_true(self.media_utils.is_playlist_icon_visible(),
47                            'Playlist icon should be visible on HU')
48        self.media_utils.click_on_playlist_icon()
49        self.media_utils.scroll_playlist_to_the_button()
50        self.media_utils.select_song_from_playlist()
51        self.media_utils.pause_media_on_hu()
52        current_phone_song_title = self.media_utils.get_song_title_from_phone()
53        current_hu_song_title = self.media_utils.get_song_title_from_hu()
54        asserts.assert_true(current_phone_song_title == current_hu_song_title,
55                            'Invalid song titles. '
56                            'Song title on phone device and HU should be the same')
57
58    def teardown_test(self):
59        self.media_utils.get_bt_dumpsys_metadata()
60        # Minimize now_playing
61        self.media_utils.minimize_now_playing()
62        #  Close YouTube Music app
63        self.media_utils.close_youtube_music_app()
64        self.call_utils.press_home()
65        super().teardown_test()
66
67
68if __name__ == '__main__':
69    common_main()
70