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_songs_tileview_fullplay(self): """ play a song until the end in the tile view """ music_app = Music(self.marionette) music_app.launch() music_app.wait_for_music_tiles_displayed() self.take_screenshot() songs = TileView(self.marionette) main_song_player_view = songs.tap_main_song() play_time = time.strptime('00:20', '%M:%S') Wait(self.marionette, timeout=30).until( lambda m: main_song_player_view.player_elapsed_time >= play_time, message='song did not reach the end') music_app.wait_for_music_tiles_displayed() self.take_screenshot() # Once the song is done, it'll return to the tile view sub_song_player_view = songs.tap_sub_song(0) play_time = time.strptime('00:10', '%M:%S') Wait(self.marionette, timeout=20).until( lambda m: sub_song_player_view.player_elapsed_time >= play_time, message = 'song did not reach the end') music_app.wait_for_music_tiles_displayed() self.take_screenshot()
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 test_select_album_play(self): # https://moztrap.mozilla.org/manage/case/4031/ music_app = Music(self.marionette) music_app.launch() # switch to albums view list_view = music_app.tap_albums_tab() # check that albums (at least one) are available albums = list_view.albums self.assertGreater(len(albums), 0, 'The mp3 file could not be found') # select an album sublist_view = albums[0].tap() # select play # This wait is timing out because of bug 862156 player_view = sublist_view.tap_play() # play for a short duration self.wait_for_condition(lambda m: player_view.player_elapsed_time == '00:05', message='Mp3 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_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_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_album_play(self): # https://moztrap.mozilla.org/manage/case/4031/ music_app = Music(self.marionette) music_app.launch() # switch to albums view list_view = music_app.tap_albums_tab() # check that albums (at least one) are available albums = list_view.albums self.assertGreater(len(albums), 0, 'no albums found') # select an album sublist_view = albums[0].tap() # select play # This wait is timing out because of bug 862156 player_view = sublist_view.tap_play() # play for a short duration self.wait_for_condition(lambda m: player_view.player_elapsed_time == '00:05') self.assertNotEqual( player_view.player_current_timestamp, player_view.player_playback_duration) # validate playback self.assertTrue(player_view.is_player_playing()) # select stop player_view.tap_play() # validate stopped playback self.assertFalse(player_view.is_player_playing())
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_album_mp3(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 albums view list_view = music_app.tap_albums_tab() # check that albums (at least one) are available albums = list_view.media self.assertGreater(len(albums), 0, 'The mp3 file could not be found') self.take_screenshot() # select an album sublist_view = albums[0].tap_first_album() self.take_screenshot() # select play # This wait is timing out because of bug 862156 player_view = sublist_view.tap_first_song() # play for a short duration play_time = time.strptime('00:03', '%M:%S') Wait(self.marionette).until( lambda m: player_view.player_elapsed_time >= play_time, message='Mp3 sample did not start playing') player_view.tap_forward() 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_album_play(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 albums view list_view = music_app.tap_albums_tab() # check that albums (at least one) are available albums = list_view.media self.assertGreater(len(albums), 0, 'The mp3 file could not be found') # select an album sublist_view = albums[0].tap_first_album() # select play # This wait is timing out because of bug 862156 player_view = sublist_view.tap_play() # play for a short duration self.wait_for_condition( lambda m: player_view.player_elapsed_time == '00:05', message='Mp3 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_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 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_empty_music(self): """https://moztrap.mozilla.org/manage/case/3668/""" # Requires there to be no songs on SDCard which is the default music_app = Music(self.marionette) music_app.launch() music_app.wait_for_empty_message_to_load()
def test_empty_music(self): # Requires there to be no songs on SDCard which is the default music_app = Music(self.marionette) music_app.launch() music_app.wait_for_empty_message_to_load() # Check that view elements are hidden when the overlay is showing. self.assertTrue(self.accessibility.is_hidden(music_app.tabs)) self.assertTrue(self.accessibility.is_hidden(music_app.views))
def prepare_app(self): music_count = WORKLOADS['heavy']['music'] tracks_per_album = 10 self.device.b2gpopulate.populate_music( music_count, tracks_per_album=tracks_per_album) app = Music(self.device.marionette) app.launch() # Bug 922610 - Wait for the music app to finish scanning time.sleep(5) self.wait_for_content_ready()
def prepare_app(self): music_count = 100 tracks_per_album = 10 self.device.b2gpopulate.populate_music( music_count, tracks_per_album=tracks_per_album) app = Music(self.device.marionette) app.launch() # Bug 922610 - Wait for the music app to finish scanning time.sleep(5) self.wait_for_content_ready()
def test_empty_music(self): # https://moztrap.mozilla.org/manage/case/3668/ # Requires there to be no songs on SDCard which is the default music_app = Music(self.marionette) music_app.launch() music_app.wait_for_empty_message_to_load() # Verify title & text when no music present self.assertEqual(music_app.empty_music_title, self.expected_title) self.assertEqual(music_app.empty_music_text, self.expected_text)
def test_select_album_play(self): music_app = Music(self.marionette) music_app.launch() music_app.wait_for_music_tiles_displayed() list_view = music_app.a11y_click_albums_tab() # check that albums (at least one) are available albums = list_view.media self.assertGreater(len(albums), 0, 'The mp3 file could not be found') # select an album by click sublist_view = albums[0].a11y_click_first_album() self.wait_for_element_displayed(*sublist_view._play_control_locator) self.assertTrue(self.accessibility.is_visible( self.marionette.find_element(*sublist_view._play_control_locator)))
def test_select_album_play(self): music_app = Music(self.marionette) music_app.launch() music_app.wait_for_music_tiles_displayed() list_view = music_app.a11y_click_albums_tab() # check that albums (at least one) are available albums = list_view.media self.assertGreater(len(albums), 0, 'The mp3 file could not be found') # select an album by click sublist_view = albums[0].a11y_click_first_album() element = Wait(self.marionette).until( expected.element_present(*sublist_view._play_control_locator)) Wait(self.marionette).until(expected.element_displayed(element)) self.assertTrue(self.accessibility.is_visible(element))
def test_select_album_play(self): """ https://moztrap.mozilla.org/manage/case/3755/ """ music_app = Music(self.marionette) music_app.launch() music_app.wait_for_music_tiles_displayed() # switch to albums view list_view = music_app.tap_albums_tab() # check that albums (at least one) are available albums = list_view.media self.assertGreater(len(albums), 0, "The mp3 file could not be found") # select an album sublist_view = albums[0].tap_first_album() # select play # This wait is timing out because of bug 862156 player_view = sublist_view.tap_play() # play for a short duration play_time = time.strptime("00:03", "%M:%S") self.wait_for_condition( lambda m: player_view.player_elapsed_time >= play_time, timeout=10, message="Mp3 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_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')