Commit d7043c37 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

Break AudioPlayerBrowserTest changeTracks into separate tests

Break test changeTracks into three separate tests, rather than do it
all in one test. And hopefully, improve test speed and robustness by
eliminating the interrupted play() -> pause() problem, which was due
due to not waiting for the play button aria-label state change.

changeTracks
  Clicks on the "next" button and tests that the "next" track plays.
  Move what was formerly in this test, to the new tests.

changeTracksPlayList
  Expands the track list by clicking on the the play-list button and
  clicks track 0. Test that the expected audio track (0) plays.

changeTracksPlayListIcon
  Expands the track list by clicking on the the play-list button and
  clicks the track 1 'Play' icon. Test that the expected audio track
  (1) plays.

Add more comments to the togglePlayState and changeVolumeLevel tests
and comments describing the new tests.

Test: browser_tests --gtest_filter=AudioPlayerBrowserTest.ChangeTr*
Bug: 835626
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: Ibfb771ab7b276fbb64e2f40c5d17221a95244d15
Reviewed-on: https://chromium-review.googlesource.com/1051306Reviewed-by: default avatarNaoki Fukino <fukino@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557434}
parent 16c3177a
...@@ -65,4 +65,14 @@ IN_PROC_BROWSER_TEST_F(AudioPlayerBrowserTest, ChangeTracks) { ...@@ -65,4 +65,14 @@ IN_PROC_BROWSER_TEST_F(AudioPlayerBrowserTest, ChangeTracks) {
StartTest(); StartTest();
} }
IN_PROC_BROWSER_TEST_F(AudioPlayerBrowserTest, ChangeTracksPlayList) {
set_test_case_name("changeTracksPlayList");
StartTest();
}
IN_PROC_BROWSER_TEST_F(AudioPlayerBrowserTest, ChangeTracksPlayListIcon) {
set_test_case_name("changeTracksPlayListIcon");
StartTest();
}
} // namespace file_manager } // namespace file_manager
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
/** /**
* Confirms that clicking the play button changes the audio player state and * Confirms that clicking the play button changes the audio player state and
* updates the play button's label. * updates the play button label.
* @return {Promise} Promise to be fulfilled with on success. * @return {Promise} Promise to be fulfilled on success.
*/ */
testcase.togglePlayState = function() { testcase.togglePlayState = function() {
var openAudio = launch('local', 'downloads', [ENTRIES.beautiful]); var openAudio = launch('local', 'downloads', [ENTRIES.beautiful]);
...@@ -50,9 +50,9 @@ testcase.togglePlayState = function() { ...@@ -50,9 +50,9 @@ testcase.togglePlayState = function() {
}; };
/** /**
* Confirms that the AudioPlayer default volume is 50 and that clicking the * Confirms that the AudioPlayer default volume is 50, and that clicking the
* volume button mutes / unmutes the volume label. * volume button mutes / unmutes the volume.
* @return {Promise} Promise to be fulfilled with on success. * @return {Promise} Promise to be fulfilled on success.
*/ */
testcase.changeVolumeLevel = function() { testcase.changeVolumeLevel = function() {
var openAudio = launch('local', 'downloads', [ENTRIES.beautiful]); var openAudio = launch('local', 'downloads', [ENTRIES.beautiful]);
...@@ -89,9 +89,9 @@ testcase.changeVolumeLevel = function() { ...@@ -89,9 +89,9 @@ testcase.changeVolumeLevel = function() {
}; };
/** /**
* Confirm that clicking "Next" and track on playlist change the current track * Confirms that the Audio Player active track changes and plays when a user
* and play state correctly. * clicks the "next" button.
* @return {Promise} Promise to be fulfilled with on success. * @return {Promise} Promise to be fulfilled on success.
*/ */
testcase.changeTracks = function() { testcase.changeTracks = function() {
var openAudio = launch('local', 'downloads', var openAudio = launch('local', 'downloads',
...@@ -100,71 +100,168 @@ testcase.changeTracks = function() { ...@@ -100,71 +100,168 @@ testcase.changeTracks = function() {
return openAudio.then(function(args) { return openAudio.then(function(args) {
appId = args[0]; appId = args[0];
}).then(function() { }).then(function() {
// While playing, the play/pause button should have 'Pause' label. // Audio player starts playing automatically
return Promise.all([
remoteCallAudioPlayer.waitForElement(
appId, 'audio-player[playing]'),
remoteCallAudioPlayer.waitForElement(
appId, ['#play[aria-label="Pause"]'])
]);
}).then(function() {
// ... and track 0 should be active.
return remoteCallAudioPlayer.waitForElement( return remoteCallAudioPlayer.waitForElement(
appId, ['#play[aria-label="Pause"]']); appId, ['.track[index="0"][active]']);
}).then(function() { }).then(function() {
// Clicking the pause button should change the playback state to pause. // Clicking the play button should
return remoteCallAudioPlayer.callRemoteTestUtil( return remoteCallAudioPlayer.callRemoteTestUtil(
'fakeMouseClick', appId, ['#play']); 'fakeMouseClick', appId, ['#play']);
}).then(function() { }).then(function() {
return remoteCallAudioPlayer.waitForElement( // ... change the playback state to pause
appId, 'audio-player:not([playing])'); return Promise.all([
remoteCallAudioPlayer.waitForElement(
appId, 'audio-player:not([playing])'),
remoteCallAudioPlayer.waitForElement(
appId, ['#play[aria-label="Play"]'])
]);
}).then(function() { }).then(function() {
// The first track should be active. // ... and track 0 should still be active.
return remoteCallAudioPlayer.waitForElement( return remoteCallAudioPlayer.waitForElement(
appId, ['.track[index="0"][active]']); appId, ['.track[index="0"][active]']);
}).then(function() { }).then(function() {
// Clicking next button should activate the second track and start playing. // Clicking the player's "next" button should
return remoteCallAudioPlayer.callRemoteTestUtil( return remoteCallAudioPlayer.callRemoteTestUtil(
'fakeMouseClick', appId, ['#next']); 'fakeMouseClick', appId, ['#next']);
}).then(function() { }).then(function() {
return remoteCallAudioPlayer.waitForElement( // ... activate and play track 1.
appId, ['.track[index="1"][active]']); return Promise.all([
remoteCallAudioPlayer.waitForElement(
appId, ['.track[index="1"][active]']),
remoteCallAudioPlayer.waitForElement(
appId, 'audio-player[playing]')
]);
});
};
/**
* Confirms that the track-list expands when the play-list button is clicked,
* then clicking on a track in the play-list, plays that track.
* @return {Promise} Promise to be fulfilled on success.
*/
testcase.changeTracksPlayList = function() {
var openAudio = launch('local', 'downloads',
[ENTRIES.beautiful, ENTRIES.newlyAdded]);
var appId;
return openAudio.then(function(args) {
appId = args[0];
}).then(function() { }).then(function() {
// Audio player starts playing automatically
return Promise.all([
remoteCallAudioPlayer.waitForElement(
appId, 'audio-player[playing]'),
remoteCallAudioPlayer.waitForElement(
appId, ['#play[aria-label="Pause"]'])
]);
}).then(function() {
// ... and track 0 should be active.
return remoteCallAudioPlayer.waitForElement( return remoteCallAudioPlayer.waitForElement(
appId, 'audio-player[playing]'); appId, ['.track[index="0"][active]']);
}).then(function() { }).then(function() {
// Pause to prepare for remaining steps. // Clicking the play button should
return remoteCallAudioPlayer.callRemoteTestUtil( return remoteCallAudioPlayer.callRemoteTestUtil(
'fakeMouseClick', appId, ['#play']); 'fakeMouseClick', appId, ['#play']);
}).then(function() { }).then(function() {
// ... change the playback state to pause,
return Promise.all([
remoteCallAudioPlayer.waitForElement(
appId, 'audio-player:not([playing])'),
remoteCallAudioPlayer.waitForElement(
appId, ['#play[aria-label="Play"]'])
]);
}).then(function() {
// ... and track 0 should still be active.
return remoteCallAudioPlayer.waitForElement( return remoteCallAudioPlayer.waitForElement(
appId, 'audio-player:not([playing])'); appId, ['.track[index="0"][active]']);
}).then(function() { }).then(function() {
// Clicking playlist button should expand track list. // Clicking the play-list button should
return remoteCallAudioPlayer.callRemoteTestUtil( return remoteCallAudioPlayer.callRemoteTestUtil(
'fakeMouseClick', appId, ['#playList']); 'fakeMouseClick', appId, ['#playList']);
}).then(function() { }).then(function() {
// ... expand the Audio Player track-list.
return remoteCallAudioPlayer.waitForElement( return remoteCallAudioPlayer.waitForElement(
appId, 'track-list[expanded]'); appId, 'track-list[expanded]');
}).then(function() { }).then(function() {
// Clicking the first track should make it active and start playing it. // Clicking on a track (track 0 here) should
return remoteCallAudioPlayer.callRemoteTestUtil( return remoteCallAudioPlayer.callRemoteTestUtil(
'fakeMouseClick', appId, ['.track[index="0"]']); 'fakeMouseClick', appId, ['.track[index="0"]']);
}).then(function() { }).then(function() {
return remoteCallAudioPlayer.waitForElement( // ... activate and start playing that track.
appId, '.track[index="0"][active]'); return Promise.all([
remoteCallAudioPlayer.waitForElement(
appId, '.track[index="0"][active]'),
remoteCallAudioPlayer.waitForElement(
appId, 'audio-player[playing]')
]);
});
};
/**
* Confirms that the track-list expands when the play-list button is clicked,
* then clicking on a track 'Play' icon in the play-list, plays that track.
* @return {Promise} Promise to be fulfilled on success.
*/
testcase.changeTracksPlayListIcon = function() {
var openAudio = launch('local', 'downloads',
[ENTRIES.beautiful, ENTRIES.newlyAdded]);
var appId;
return openAudio.then(function(args) {
appId = args[0];
}).then(function() {
// Audio player starts playing automatically
return Promise.all([
remoteCallAudioPlayer.waitForElement(
appId, 'audio-player[playing]'),
remoteCallAudioPlayer.waitForElement(
appId, ['#play[aria-label="Pause"]'])
]);
}).then(function() { }).then(function() {
// ... and track 0 should be active.
return remoteCallAudioPlayer.waitForElement( return remoteCallAudioPlayer.waitForElement(
appId, 'audio-player[playing]'); appId, ['.track[index="0"][active]']);
}).then(function() { }).then(function() {
// Pause to prepare for remaining steps. // Clicking the play button should
return remoteCallAudioPlayer.callRemoteTestUtil( return remoteCallAudioPlayer.callRemoteTestUtil(
'fakeMouseClick', appId, ['#play']); 'fakeMouseClick', appId, ['#play']);
}).then(function() { }).then(function() {
// ... change the playback state to pause,
return Promise.all([
remoteCallAudioPlayer.waitForElement(
appId, 'audio-player:not([playing])'),
remoteCallAudioPlayer.waitForElement(
appId, ['#play[aria-label="Play"]'])
]);
}).then(function() {
// ... and track 0 should still be active.
return remoteCallAudioPlayer.waitForElement( return remoteCallAudioPlayer.waitForElement(
appId, 'audio-player:not([playing])'); appId, ['.track[index="0"][active]']);
}).then(function() { }).then(function() {
// Clicking the play icon on the second should make it active, and start // Clicking the play-list button should
// playing.
return remoteCallAudioPlayer.callRemoteTestUtil( return remoteCallAudioPlayer.callRemoteTestUtil(
'fakeMouseClick', appId, ['.track[index="1"] .icon']); 'fakeMouseClick', appId, ['#playList']);
}).then(function() { }).then(function() {
// ... expand the Audio Player track-list.
return remoteCallAudioPlayer.waitForElement( return remoteCallAudioPlayer.waitForElement(
appId, '.track[index="1"][active]'); appId, 'track-list[expanded]');
}).then(function() { }).then(function() {
return remoteCallAudioPlayer.waitForElement( // Clicking a track (track 1 here) 'Play' icon should
appId, 'audio-player[playing]'); return remoteCallAudioPlayer.callRemoteTestUtil(
'fakeMouseClick', appId, ['.track[index="1"] .icon']);
}).then(function() {
// ... activate and start playing that track.
return Promise.all([
remoteCallAudioPlayer.waitForElement(
appId, '.track[index="1"][active]'),
remoteCallAudioPlayer.waitForElement(
appId, 'audio-player[playing]')
]);
}); });
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment