| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 'use strict'; |
| 6 |
| 7 /** |
| 8 * Confirms that the play button toggles play state and it's labels. |
| 9 * @return {Promise} Promise to be fulfilled with on success. |
| 10 */ |
| 11 testcase.togglePlayState = function() { |
| 12 var openAudio = launch('local', 'downloads', [ENTRIES.beautiful]); |
| 13 var appId; |
| 14 return openAudio.then(function(args) { |
| 15 appId = args[0]; |
| 16 }).then(function() { |
| 17 // Audio player should start playing automatically. |
| 18 return remoteCallAudioPlayer.waitForElement( |
| 19 appId, 'audio-player[playing]'); |
| 20 }).then(function() { |
| 21 // While playing, the play/pause button should have 'Pause' label. |
| 22 return remoteCallAudioPlayer.waitForElement( |
| 23 appId, ['#play[aria-label="Pause"]']); |
| 24 }).then(function() { |
| 25 // Clicking the pause button should change the playback state to pause. |
| 26 return remoteCallAudioPlayer.callRemoteTestUtil( |
| 27 'fakeMouseClick', appId, ['#play']); |
| 28 }).then(function() { |
| 29 return remoteCallAudioPlayer.waitForElement( |
| 30 appId, 'audio-player:not([playing])'); |
| 31 }).then(function() { |
| 32 // ... and the play/pause button should have 'Play' label. |
| 33 return remoteCallAudioPlayer.waitForElement( |
| 34 appId, ['#play[aria-label="Play"]']); |
| 35 }); |
| 36 }; |
| 37 |
| 38 /** |
| 39 * Confirms that the default volume is 50 and volume button mutes/unmutes audio. |
| 40 * @return {Promise} Promise to be fulfilled with on success. |
| 41 */ |
| 42 testcase.changeVolumeLevel = function() { |
| 43 var openAudio = launch('local', 'downloads', [ENTRIES.beautiful]); |
| 44 var appId; |
| 45 return openAudio.then(function(args) { |
| 46 appId = args[0]; |
| 47 }).then(function() { |
| 48 // The default volume level should be 50. |
| 49 return remoteCallAudioPlayer.waitForElement( |
| 50 appId, ['control-panel[volume="50"]']); |
| 51 }).then(function() { |
| 52 // Clicking volume button should mute the player. |
| 53 return remoteCallAudioPlayer.callRemoteTestUtil( |
| 54 'fakeMouseClick', appId, ['#volumeButton']); |
| 55 }).then(function() { |
| 56 return Promise.all([ |
| 57 remoteCallAudioPlayer.waitForElement( |
| 58 appId, ['control-panel[volume="0"]']), |
| 59 remoteCallAudioPlayer.waitForElement( |
| 60 appId, ['#volumeButton[aria-label="Unmute"]']) |
| 61 ]); |
| 62 }).then(function() { |
| 63 // Clicking volume button again should restore volume. |
| 64 return remoteCallAudioPlayer.callRemoteTestUtil( |
| 65 'fakeMouseClick', appId, ['#volumeButton']); |
| 66 }).then(function() { |
| 67 return Promise.all([ |
| 68 remoteCallAudioPlayer.waitForElement( |
| 69 appId, ['control-panel[volume="50"]']), |
| 70 remoteCallAudioPlayer.waitForElement( |
| 71 appId, ['#volumeButton[aria-label="Mute"]']) |
| 72 ]); |
| 73 }); |
| 74 }; |
| 75 |
| 76 /** |
| 77 * Confirm that clicking "Next" and track on playlist change the current track |
| 78 * and play state correctly. |
| 79 * @return {Promise} Promise to be fulfilled with on success. |
| 80 */ |
| 81 testcase.changeTracks = function() { |
| 82 var openAudio = launch('local', 'downloads', |
| 83 [ENTRIES.beautiful, ENTRIES.newlyAdded]); |
| 84 var appId; |
| 85 return openAudio.then(function(args) { |
| 86 appId = args[0]; |
| 87 }).then(function() { |
| 88 // While playing, the play/pause button should have 'Pause' label. |
| 89 return remoteCallAudioPlayer.waitForElement( |
| 90 appId, ['#play[aria-label="Pause"]']); |
| 91 }).then(function() { |
| 92 // Clicking the pause button should change the playback state to pause. |
| 93 return remoteCallAudioPlayer.callRemoteTestUtil( |
| 94 'fakeMouseClick', appId, ['#play']); |
| 95 }).then(function() { |
| 96 return remoteCallAudioPlayer.waitForElement( |
| 97 appId, 'audio-player:not([playing])'); |
| 98 }).then(function() { |
| 99 // The first track should be active. |
| 100 return remoteCallAudioPlayer.waitForElement( |
| 101 appId, ['.track[index="0"][active]']); |
| 102 }).then(function() { |
| 103 // Clicking next button should activate the second track and start playing. |
| 104 return remoteCallAudioPlayer.callRemoteTestUtil( |
| 105 'fakeMouseClick', appId, ['#next']); |
| 106 }).then(function() { |
| 107 return remoteCallAudioPlayer.waitForElement( |
| 108 appId, ['.track[index="1"][active]']); |
| 109 }).then(function() { |
| 110 return remoteCallAudioPlayer.waitForElement( |
| 111 appId, 'audio-player[playing]'); |
| 112 }).then(function() { |
| 113 // Pause to prepare for remaining steps. |
| 114 return remoteCallAudioPlayer.callRemoteTestUtil( |
| 115 'fakeMouseClick', appId, ['#play']); |
| 116 }).then(function() { |
| 117 return remoteCallAudioPlayer.waitForElement( |
| 118 appId, 'audio-player:not([playing])'); |
| 119 }).then(function() { |
| 120 // Clicking playlist button should expand track list. |
| 121 return remoteCallAudioPlayer.callRemoteTestUtil( |
| 122 'fakeMouseClick', appId, ['#playList']); |
| 123 }).then(function() { |
| 124 return remoteCallAudioPlayer.waitForElement( |
| 125 appId, 'track-list[expanded]'); |
| 126 }).then(function() { |
| 127 // Clicking the first track should make it active, but shouldn't start |
| 128 // playing. |
| 129 return remoteCallAudioPlayer.callRemoteTestUtil( |
| 130 'fakeMouseClick', appId, ['.track[index="0"]']); |
| 131 }).then(function() { |
| 132 return remoteCallAudioPlayer.waitForElement( |
| 133 appId, '.track[index="0"][active]'); |
| 134 }).then(function() { |
| 135 return remoteCallAudioPlayer.waitForElement( |
| 136 appId, 'audio-player:not([playing])'); |
| 137 }).then(function() { |
| 138 // Clicking the play icon on the second should make it active, and start |
| 139 // playing. |
| 140 return remoteCallAudioPlayer.callRemoteTestUtil( |
| 141 'fakeMouseClick', appId, ['.track[index="1"] .icon']); |
| 142 }).then(function() { |
| 143 return remoteCallAudioPlayer.waitForElement( |
| 144 appId, '.track[index="1"][active]'); |
| 145 }).then(function() { |
| 146 return remoteCallAudioPlayer.waitForElement( |
| 147 appId, 'audio-player[playing]'); |
| 148 }); |
| 149 }; |
| OLD | NEW |