Chromium Code Reviews| Index: ui/file_manager/integration_tests/audio_player/click_control_buttons.js |
| diff --git a/ui/file_manager/integration_tests/audio_player/click_control_buttons.js b/ui/file_manager/integration_tests/audio_player/click_control_buttons.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b2e979821d23d315e4537a926b7afee64c5b48f5 |
| --- /dev/null |
| +++ b/ui/file_manager/integration_tests/audio_player/click_control_buttons.js |
| @@ -0,0 +1,150 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +'use strict'; |
| + |
| +/** |
| + * Confirms that the play button toggles play state and it's labels. |
| + * @return {Promise} Promise to be fulfilled with on success. |
| + */ |
| +testcase.togglePlayState = function() { |
| + var openAudio = launch('local', 'downloads', [ENTRIES.beautiful]); |
| + var appId; |
| + return openAudio.then(function(args) { |
| + appId = args[0]; |
| + }).then(function() { |
| + // Audio player should start playing automatically. |
| + return remoteCallAudioPlayer.waitForElement( |
| + appId, 'audio-player[playing]'); |
| + }).then(function() { |
| + // While playing, the play/pause button should have 'Pause' label. |
| + return remoteCallAudioPlayer.waitForElement( |
| + appId, ['#play[aria-label="Pause"]']); |
| + }).then(function() { |
| + // Clicking the pause button should change the playback state to pause. |
| + return remoteCallAudioPlayer.callRemoteTestUtil( |
| + 'fakeMouseClick', appId, ['#play']); |
| + }).then(function() { |
| + return remoteCallAudioPlayer.waitForElement( |
| + appId, 'audio-player:not([playing])'); |
| + }).then(function() { |
| + // ... and the play/pause button should have 'Play' label. |
| + return remoteCallAudioPlayer.waitForElement( |
| + appId, ['#play[aria-label="Play"]']); |
| + }); |
| +}; |
| + |
| +/** |
| + * Confirms that the default volume is 50 and volume button mutes/unmutes audio. |
| + * @return {Promise} Promise to be fulfilled with on success. |
| + */ |
| +testcase.changeVolumeLevel = function() { |
| + var openAudio = launch('local', 'downloads', [ENTRIES.beautiful]); |
| + var appId; |
| + return openAudio.then(function(args) { |
| + appId = args[0]; |
| + }).then(function() { |
| + // The default volume level should be 50. |
| + return remoteCallAudioPlayer.waitForElement( |
| + appId, ['control-panel[volume="50"]']); |
| + }).then(function() { |
| + // Clicking volume button should mute the player. |
| + return remoteCallAudioPlayer.callRemoteTestUtil( |
| + 'fakeMouseClick', appId, ['#volumeButton']); |
| + }).then(function() { |
| + return Promise.all([ |
| + remoteCallAudioPlayer.waitForElement( |
| + appId, ['control-panel[volume="0"]']), |
| + remoteCallAudioPlayer.waitForElement( |
| + appId, ['#volumeButton[aria-label="Unmute"]']) |
| + ]); |
| + }).then(function() { |
| + // Clicking volume button again should restore volume. |
| + return remoteCallAudioPlayer.callRemoteTestUtil( |
| + 'fakeMouseClick', appId, ['#volumeButton']); |
| + }).then(function() { |
| + return Promise.all([ |
| + remoteCallAudioPlayer.waitForElement( |
| + appId, ['control-panel[volume="50"]']), |
| + remoteCallAudioPlayer.waitForElement( |
| + appId, ['#volumeButton[aria-label="Mute"]']) |
| + ]); |
| + }); |
| +}; |
| + |
| +/** |
| + * Confirm that clicking "Next" and track on playlist change the current track |
| + * and play state correctly. |
| + * @return {Promise} Promise to be fulfilled with on success. |
| + */ |
| +testcase.changeTracks = function() { |
| + var openAudio = launch('local', 'downloads', |
| + [ENTRIES.beautiful, ENTRIES.newlyAdded]); |
| + var appId; |
| + return openAudio.then(function(args) { |
| + appId = args[0]; |
| + }).then(function() { |
| + // While playing, the play/pause button should have 'Pause' label. |
| + return remoteCallAudioPlayer.waitForElement( |
| + appId, ['#play[aria-label="Pause"]']); |
| + }).then(function() { |
| + // Clicking the pause button should change the playback state to pause. |
| + return remoteCallAudioPlayer.callRemoteTestUtil( |
| + 'fakeMouseClick', appId, ['#play']); |
| + }).then(function() { |
| + return remoteCallAudioPlayer.waitForElement( |
| + appId, 'audio-player:not([playing])'); |
| + }).then(function() { |
| + // The first track should be active. |
| + return remoteCallAudioPlayer.waitForElement( |
| + appId, ['.track[index="0"][active]']); |
| + }).then(function() { |
| + // Clicking next button should activate the second track and start playing. |
| + return remoteCallAudioPlayer.callRemoteTestUtil( |
| + 'fakeMouseClick', appId, ['#next']); |
| + }).then(function() { |
| + return Promise.all([ |
| + remoteCallAudioPlayer.waitForElement( |
| + appId, ['.track[index="1"][active]']), |
| + remoteCallAudioPlayer.waitForElement( |
| + appId, 'audio-player[playing]') |
| + ]); |
| + }).then(function() { |
| + // Pause to prepare for remaining steps. |
| + return remoteCallAudioPlayer.callRemoteTestUtil( |
| + 'fakeMouseClick', appId, ['#play']); |
| + }).then(function() { |
| + return remoteCallAudioPlayer.waitForElement( |
| + appId, 'audio-player:not([playing])'); |
| + }).then(function() { |
| + // Clicking playlist button should expand track list. |
| + return remoteCallAudioPlayer.callRemoteTestUtil( |
| + 'fakeMouseClick', appId, ['#playList']); |
| + }).then(function() { |
| + return remoteCallAudioPlayer.waitForElement( |
| + appId, 'track-list[expanded]'); |
| + }).then(function() { |
| + // Clicking the first track should make it active, but shouldn't start |
| + // playing. |
| + return remoteCallAudioPlayer.callRemoteTestUtil( |
| + 'fakeMouseClick', appId, ['.track[index="0"]']); |
| + }).then(function() { |
| + return remoteCallAudioPlayer.waitForElement( |
| + appId, '.track[index="0"][active]'); |
|
yawano
2015/12/16 08:01:44
optional nit: how about to put this in the Promise
fukino
2015/12/16 08:26:34
Both way should work, but I think sequential proce
yawano
2015/12/16 08:53:39
Yes, both will work. I added a comment just for co
fukino
2015/12/16 09:13:51
Oops, I overlooked #107. I made it sequential.
Tha
|
| + }).then(function() { |
| + return remoteCallAudioPlayer.waitForElement( |
| + appId, 'audio-player:not([playing])'); |
| + }).then(function() { |
| + // Clicking the play icon on the second should make it active, and start |
| + // playing. |
| + return remoteCallAudioPlayer.callRemoteTestUtil( |
| + 'fakeMouseClick', appId, ['.track[index="1"] .icon']); |
| + }).then(function() { |
| + return remoteCallAudioPlayer.waitForElement( |
| + appId, '.track[index="1"][active]'); |
|
yawano
2015/12/16 08:01:44
optional nit: same with comment at #134.
fukino
2015/12/16 08:26:34
ditto
|
| + }).then(function() { |
| + return remoteCallAudioPlayer.waitForElement( |
| + appId, 'audio-player[playing]'); |
| + }); |
| +}; |