• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
22from utilities.video_utils_service import VideoRecording
23
24
25class IsNowPlayingLabelDisplayed(bluetooth_base_test.BluetoothBaseTest):
26
27    def setup_class(self):
28        super().setup_class()
29        self.media_utils = MediaUtils(self.target, self.discoverer)
30        self.common_utils = CommonUtils(self.target, self.discoverer)
31
32    def setup_test(self):
33        self.common_utils.grant_local_mac_address_permission()
34        logging.info("\tInitializing video services on Target")
35        self.video_utils_service_target = VideoRecording(self.target,self.__class__.__name__)
36        logging.info("Enabling video recording for Target")
37        self.video_utils_service_target.enable_screen_recording()
38        self.common_utils.enable_wifi_on_phone_device()
39        self.bt_utils.pair_primary_to_secondary()
40
41    def test_is_now_paying_label_displayed(self):
42        """Tests is Now Playing label displayed on HU"""
43        self.media_utils.open_media_app_on_hu()
44        self.media_utils.open_youtube_music_app()
45        self.call_utils.wait_with_log(5)
46        logging.info("Getting song title from phone device: %s", self.media_utils.get_song_title_from_phone())
47        self.media_utils.pause_media_on_hu()
48        self.media_utils.maximize_now_playing()
49        asserts.assert_true(self.media_utils.is_now_playing_label_displayed(),
50                            '<Now Playing> label should be displayed')
51
52    def teardown_test(self):
53        # Close YouTube Music app
54        self.media_utils.close_youtube_music_app()
55        self.call_utils.press_home()
56        logging.info("Stopping the screen recording on Target")
57        self.video_utils_service_target.stop_screen_recording()
58        logging.info("Pull the screen recording from Target")
59        self.video_utils_service_target.pull_recording_file(self.log_path)
60        logging.info("delete the screen recording from the Target")
61        self.video_utils_service_target.delete_screen_recording_from_device()
62        super().teardown_test()
63
64
65if __name__ == '__main__':
66    common_main()
67