def test_music_songs_3gp(self): """https://moztrap.mozilla.org/manage/case/4031/""" music_app = Music(self.marionette) music_app.launch() music_app.wait_for_music_tiles_displayed() self.take_screenshot() # switch to songs view list_view = music_app.tap_songs_tab() # check that songs (at least one) are available songs = list_view.media self.assertGreater(len(songs), 0, 'The 3gp file could not be found') self.take_screenshot() player_view = songs[0].tap_first_song() play_time = time.strptime('00:03', '%M:%S') Wait(self.marionette).until( lambda m: player_view.player_elapsed_time >= play_time, message='3gp sample did not start playing') # validate playback self.assertTrue(player_view.is_player_playing(), 'The player is not playing') # select stop, then FF to the end of the song player_view.tap_play() ff_button = self.marionette.find_element( *self._player_controls_next_locator) Actions(self.marionette).tap(ff_button).perform() self.take_screenshot()
def test_music_change_rating(self): """ https://moztrap.mozilla.org/manage/case/2683/ """ music_app = Music(self.marionette) music_app.launch() music_app.wait_for_music_tiles_displayed() # switch to songs view, and play the first one on the list list_view = music_app.tap_songs_tab() songs = list_view.media self.assertGreater(len(songs), 0, 'The ogg file could not be found') player_view = songs[0].tap_first_song() # wait until the player view is shown, then pause the play play_time = time.strptime('00:02', '%M:%S') Wait(self.marionette).until(lambda m: player_view.player_elapsed_time >= play_time) player_view.tap_play() self.assertFalse(player_view.is_player_playing(), 'The player did not stop playing') # give rating of 4 player_view.tap_star(4) player_view.tap_cover_in_player_view() # tap again in case the overlay disappears due to timeout Wait(self.marionette).until(lambda m: player_view.star_rating == 4) #change the rating to 1 player_view.tap_star(1) player_view.tap_cover_in_player_view() # tap again in case the overlay disappears due to timeout Wait(self.marionette).until(lambda m: player_view.star_rating == 1)
def test_select_songs_play_3gp_file(self): music_app = Music(self.marionette) music_app.launch() # switch to songs view list_view = music_app.tap_songs_tab() # check that songs (at least one) are available songs = list_view.media self.assertGreater(len(songs), 0, 'The 3gp file could not be found') player_view = songs[0].tap_first_song() self.wait_for_condition( lambda m: player_view.player_elapsed_time == '00:05', message='3gp sample did not start playing') # validate playback self.assertTrue(player_view.is_player_playing(), 'The player is not playing') # select stop player_view.tap_play() # validate stopped playback self.assertFalse(player_view.is_player_playing(), 'The player did not stop playing')
def test_music_songview_fullplay(self): """ play a song until the end in the song list view """ music_app = Music(self.marionette) music_app.launch() music_app.wait_for_music_tiles_displayed() self.take_screenshot() # switch to songs view and play it from there too list_view = music_app.tap_songs_tab() music_app.wait_for_view_displayed('Songs') self.take_screenshot() songs = list_view.media from_list_player_view = songs[0].tap_first_song() play_time = time.strptime('00:20', '%M:%S') Wait(self.marionette, timeout=30).until( lambda m: from_list_player_view.player_elapsed_time >= play_time, message='song did not reach the end') # wait until next song kicks in (elapsed time will reset) Wait(self.marionette, timeout = 30).until( lambda m: from_list_player_view.player_elapsed_time < play_time, message='next song did not start') # once the first song completes, it will play the next song automatically play_time = time.strptime('00:13', '%M:%S') Wait(self.marionette, timeout=20).until( lambda m: from_list_player_view.player_elapsed_time >= play_time, message='song did not reach the end') music_app.wait_for_view_displayed('Songs') self.take_screenshot()
def test_background_music_playback(self): self.push_resource(os.path.abspath('source/MP3_Au4.mp3')) lock_screen = LockScreen(self.marionette) homescreen = lock_screen.unlock() self.wait_for_condition(lambda m: self.apps.displayed_app.name == homescreen.name) music_app = Music(self.marionette) music_app.launch() music_app.wait_for_music_tiles_displayed() # switch to songs view list_view = music_app.tap_songs_tab() # check that songs (at least one) are available songs = list_view.media self.assertGreater(len(songs), 0, 'The file could not be found') player_view = songs[0].tap_first_song() play_time = time.strptime('00:03', '%M:%S') self.wait_for_condition(lambda m: player_view.player_elapsed_time >= play_time) # validate playback self.assertTrue(player_view.is_player_playing(), 'The player is not playing') self.marionette.switch_to_frame() self.device.turn_screen_off() print "" print "Running Music Test (screen off)" self.runPowerTest("background_music_playback", "Music", "music")
def test_music_songs_3gp(self): """https://moztrap.mozilla.org/manage/case/4031/""" music_app = Music(self.marionette) music_app.launch() music_app.wait_for_music_tiles_displayed() self.take_screenshot() # switch to songs view list_view = music_app.tap_songs_tab() # check that songs (at least one) are available songs = list_view.media self.assertGreater(len(songs), 0, 'The 3gp file could not be found') self.take_screenshot() player_view = songs[0].tap_first_song() play_time = time.strptime('00:03', '%M:%S') Wait(self.marionette).until( lambda m: player_view.player_elapsed_time >= play_time, message='3gp sample did not start playing') # validate playback self.assertTrue(player_view.is_player_playing(), 'The player is not playing') # select stop, then FF to the end of the song player_view.tap_play() player_view.tap_forward() self.take_screenshot()
def test_music_share_ringtone(self): """ https://moztrap.mozilla.org/manage/case/2683/ """ music_app = Music(self.marionette) music_app.launch() music_app.wait_for_music_tiles_displayed() # switch to songs view, and play the first one on the list list_view = music_app.tap_songs_tab() songs = list_view.media self.assertGreater(len(songs), 0, 'The ogg file could not be found') player_view = songs[0].tap_first_song() # wait until the player view is shown, then tap the share button play_time = time.strptime('00:01', '%M:%S') Wait(self.marionette).until(lambda m: player_view.player_elapsed_time >= play_time) activities = player_view.tap_share_button() ringtone = activities.share_to_ringtones() ringtone.tap_save() system = System(self.marionette) self.marionette.switch_to_frame() system.wait_for_notification_toaster_displayed(message="Ringtone set as default.") system.wait_for_notification_toaster_not_displayed() settings = Settings(self.marionette) settings.launch() sound = settings.open_sound_settings() # desktop b2g doesn't have this option visible, see bug 1130538 if sound.ring_tone_selector_visible: self.assertEqual(sound.current_ring_tone, 'MUS_0001')
def test_music_songview_fullplay(self): """ play a song until the end in the song list view """ music_app = Music(self.marionette) music_app.launch() music_app.wait_for_music_tiles_displayed() self.take_screenshot() # switch to songs view and play it from there too list_view = music_app.tap_songs_tab() music_app.wait_for_view_displayed('Songs') self.take_screenshot() songs = list_view.media from_list_player_view = songs[0].tap_first_song() play_time = time.strptime('00:20', '%M:%S') Wait(self.marionette, timeout=30).until( lambda m: from_list_player_view.player_elapsed_time >= play_time, message='song did not reach the end') # wait until next song kicks in (elapsed time will reset) Wait(self.marionette, timeout=30).until( lambda m: from_list_player_view.player_elapsed_time < play_time, message='next song did not start') # once the first song completes, it will play the next song automatically play_time = time.strptime('00:13', '%M:%S') Wait(self.marionette, timeout=20).until( lambda m: from_list_player_view.player_elapsed_time >= play_time, message='song did not reach the end') music_app.wait_for_view_displayed('Songs') self.take_screenshot()
def test_music_change_rating(self): """ https://moztrap.mozilla.org/manage/case/2683/ """ music_app = Music(self.marionette) music_app.launch() music_app.wait_for_music_tiles_displayed() # switch to songs view, and play the first one on the list list_view = music_app.tap_songs_tab() songs = list_view.media self.assertGreater(len(songs), 0, 'The ogg file could not be found') player_view = songs[0].tap_first_song() # wait until the player view is shown, then pause the play play_time = time.strptime('00:02', '%M:%S') Wait(self.marionette).until( lambda m: player_view.player_elapsed_time >= play_time) player_view.tap_play() self.assertFalse(player_view.is_player_playing(), 'The player did not stop playing') # give rating of 4 player_view.tap_star(4) player_view.tap_cover_in_player_view( ) # tap again in case the overlay disappears due to timeout Wait(self.marionette).until(lambda m: player_view.star_rating == 4) #change the rating to 1 player_view.tap_star(1) player_view.tap_cover_in_player_view( ) # tap again in case the overlay disappears due to timeout Wait(self.marionette).until(lambda m: player_view.star_rating == 1)
def test_select_songs_play_3gp_file(self): """https://moztrap.mozilla.org/manage/case/4031/""" music_app = Music(self.marionette) music_app.launch() music_app.wait_for_music_tiles_displayed() # switch to songs view list_view = music_app.tap_songs_tab() # check that songs (at least one) are available songs = list_view.media self.assertGreater(len(songs), 0, 'The 3gp file could not be found') player_view = songs[0].tap_first_song() play_time = time.strptime('00:03', '%M:%S') self.wait_for_condition( lambda m: player_view.player_elapsed_time >= play_time, timeout=10, message='3gp sample did not start playing') # validate playback self.assertTrue(player_view.is_player_playing(), 'The player is not playing') # select stop player_view.tap_play() # validate stopped playback self.assertFalse(player_view.is_player_playing(), 'The player did not stop playing')
def test_select_songs_play_3gp_file(self): music_app = Music(self.marionette) music_app.launch() # switch to songs view list_view = music_app.tap_songs_tab() # check that songs (at least one) are available songs = list_view.media self.assertGreater(len(songs), 0, 'The 3gp file could not be found') player_view = songs[0].tap_first_song() self.wait_for_condition(lambda m: player_view.player_elapsed_time == '00:05', message='3gp sample did not start playing') # validate playback self.assertTrue(player_view.is_player_playing(), 'The player is not playing') # select stop player_view.tap_play() # validate stopped playback self.assertFalse(player_view.is_player_playing(), 'The player did not stop playing')
def music_playback(self, screen_flag): self.push_resource(os.path.abspath('source/MP3_Au4.mp3')) lock_screen = LockScreen(self.marionette) homescreen = lock_screen.unlock() #self.wait_for_condition(lambda m: self.apps.displayed_app.name == homescreen.name) music_app = Music(self.marionette) music_app.launch() music_app.wait_for_music_tiles_displayed() # switch to songs view list_view = music_app.tap_songs_tab() # check that songs (at least one) are available songs = list_view.media self.assertGreater(len(songs), 0, 'The file could not be found') player_view = songs[0].tap_first_song() play_time = time.strptime('00:10', '%M:%S') self.wait_for_condition(lambda m: player_view.player_elapsed_time >= play_time) # validate playback # self.assertTrue(player_view.is_player_playing(), 'The player is not playing') self.marionette.switch_to_frame() print "" if screen_flag: print "Running Music Test (screen on)" test_name = "music_playback" else: self.device.turn_screen_off() print "Running Music Test (screen off)" test_name = "background_music_playback" self.runPowerTest(test_name, "Music", "music")
def test_music_share_ringtone(self): """ https://moztrap.mozilla.org/manage/case/2683/ """ music_app = Music(self.marionette) music_app.launch() music_app.wait_for_music_tiles_displayed() # switch to songs view, and play the first one on the list list_view = music_app.tap_songs_tab() songs = list_view.media self.assertGreater(len(songs), 0, 'The ogg file could not be found') player_view = songs[0].tap_first_song() # wait until the player view is shown, then tap the share button play_time = time.strptime('00:01', '%M:%S') Wait(self.marionette).until( lambda m: player_view.player_elapsed_time >= play_time) activities = player_view.tap_share_button() ringtone = activities.share_to_ringtones() ringtone.tap_save() system = System(self.marionette) self.marionette.switch_to_frame() system.wait_for_notification_toaster_displayed( message="Ringtone set as default.") system.wait_for_notification_toaster_not_displayed() settings = Settings(self.marionette) settings.launch() sound = settings.open_sound() # desktop b2g doesn't have this option visible, see bug 1130538 if sound.ring_tone_selector_visible: self.assertEqual(sound.current_ring_tone, 'MUS_0001')