Chromium Code Reviews| 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 Promise.all([ | |
| 108 remoteCallAudioPlayer.waitForElement( | |
| 109 appId, ['.track[index="1"][active]']), | |
| 110 remoteCallAudioPlayer.waitForElement( | |
| 111 appId, 'audio-player[playing]') | |
| 112 ]); | |
| 113 }).then(function() { | |
| 114 // Pause to prepare for remaining steps. | |
| 115 return remoteCallAudioPlayer.callRemoteTestUtil( | |
| 116 'fakeMouseClick', appId, ['#play']); | |
| 117 }).then(function() { | |
| 118 return remoteCallAudioPlayer.waitForElement( | |
| 119 appId, 'audio-player:not([playing])'); | |
| 120 }).then(function() { | |
| 121 // Clicking playlist button should expand track list. | |
| 122 return remoteCallAudioPlayer.callRemoteTestUtil( | |
| 123 'fakeMouseClick', appId, ['#playList']); | |
| 124 }).then(function() { | |
| 125 return remoteCallAudioPlayer.waitForElement( | |
| 126 appId, 'track-list[expanded]'); | |
| 127 }).then(function() { | |
| 128 // Clicking the first track should make it active, but shouldn't start | |
| 129 // playing. | |
| 130 return remoteCallAudioPlayer.callRemoteTestUtil( | |
| 131 'fakeMouseClick', appId, ['.track[index="0"]']); | |
| 132 }).then(function() { | |
| 133 return remoteCallAudioPlayer.waitForElement( | |
| 134 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
| |
| 135 }).then(function() { | |
| 136 return remoteCallAudioPlayer.waitForElement( | |
| 137 appId, 'audio-player:not([playing])'); | |
| 138 }).then(function() { | |
| 139 // Clicking the play icon on the second should make it active, and start | |
| 140 // playing. | |
| 141 return remoteCallAudioPlayer.callRemoteTestUtil( | |
| 142 'fakeMouseClick', appId, ['.track[index="1"] .icon']); | |
| 143 }).then(function() { | |
| 144 return remoteCallAudioPlayer.waitForElement( | |
| 145 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
| |
| 146 }).then(function() { | |
| 147 return remoteCallAudioPlayer.waitForElement( | |
| 148 appId, 'audio-player[playing]'); | |
| 149 }); | |
| 150 }; | |
| OLD | NEW |