Add an audio-only pause/play test.
The test class has been updated to take a new parameter 'elementType' that is used to control whether the test should test audio or video elements.
Added a new control file for an audio-only pause/play test.
BUG=chromium:740464
TEST=locally
Change-Id: Ifa54db4d1912207c33b4747298b3072907095559
Reviewed-on: https://chromium-review.googlesource.com/571740
Commit-Ready: Harpreet Grewal <harpreet@chromium.org>
Tested-by: Harpreet Grewal <harpreet@chromium.org>
Reviewed-by: Harpreet Grewal <harpreet@chromium.org>
diff --git a/client/site_tests/webrtc_PausePlayPeerConnections/control.audio b/client/site_tests/webrtc_PausePlayPeerConnections/control.audio
new file mode 100644
index 0000000..7f203b5
--- /dev/null
+++ b/client/site_tests/webrtc_PausePlayPeerConnections/control.audio
@@ -0,0 +1,25 @@
+# Copyright 2017 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+AUTHOR = "malmnas@google.com, hangouts-engprod-sto@google.com"
+NAME = "webrtc_PausePlayPeerConnections.audio"
+PURPOSE = "Ensures frequent pause and plays of peer connection streams work"
+CRITERIA = "Fails if the tab freezes during the test"
+ATTRIBUTES = "suite:hotrod, suite:bluestreak"
+TIME = "MEDIUM"
+TEST_CATEGORY = "Stress"
+TEST_CLASS = "audio"
+TEST_TYPE = "client"
+BUG_TEMPLATE = {
+ "labels": ["OS-Chrome"],
+ "components": ["OS>Kernel>Audio"],
+}
+
+DOC = """
+This test starts 10 peer connections with audio streams.
+The tests randomly pauses and plays the streams.
+"""
+
+job.run_test("webrtc_PausePlayPeerConnections", element_type='audio')
+
diff --git a/client/site_tests/webrtc_PausePlayPeerConnections/control.video b/client/site_tests/webrtc_PausePlayPeerConnections/control.video
index 25ef090..694a3fe 100644
--- a/client/site_tests/webrtc_PausePlayPeerConnections/control.video
+++ b/client/site_tests/webrtc_PausePlayPeerConnections/control.video
@@ -6,7 +6,7 @@
NAME = "webrtc_PausePlayPeerConnections.video"
PURPOSE = "Ensures frequent pause and plays of peer connection streams work"
CRITERIA = "Fails if the tab freezes during the test"
-ATTRIBUTES = "suite:hotrod"
+ATTRIBUTES = "suite:hotrod, suite:bluestreak"
TIME = "MEDIUM"
TEST_CATEGORY = "Stress"
TEST_CLASS = "video"
@@ -23,5 +23,5 @@
This is a regression test for bug 718369.
"""
-job.run_test("webrtc_PausePlayPeerConnections")
+job.run_test("webrtc_PausePlayPeerConnections", element_type='video')
diff --git a/client/site_tests/webrtc_PausePlayPeerConnections/pause-play.js b/client/site_tests/webrtc_PausePlayPeerConnections/pause-play.js
index 44c3d51..6056897 100644
--- a/client/site_tests/webrtc_PausePlayPeerConnections/pause-play.js
+++ b/client/site_tests/webrtc_PausePlayPeerConnections/pause-play.js
@@ -14,7 +14,7 @@
}
/**
- * FeedTable stores all video elements.
+ * FeedTable stores all elements.
*/
class FeedTable {
constructor() {
@@ -24,49 +24,45 @@
this.row = this.testTable.insertRow(-1);
}
- addNewCell() {
+ addNewCell(elementType) {
if (this.col == this.numCols) {
this.row = this.testTable.insertRow(-1);
this.col = 0;
}
var newCell = this.row.insertCell(-1);
- var video = document.createElement('video');
- video.autoplay = false;
- newCell.appendChild(video);
+ var element = document.createElement(elementType);
+ element.autoplay = false;
+ newCell.appendChild(element);
this.col++;
- return video;
+ return element;
}
}
/**
* A simple loopback connection;
- * - localConnection is fed video from local camera
+ * - localConnection is fed video/audio from source
* - localConnection is linked to remoteConnection
* - remoteConnection is displayed in the given videoElement
*/
class PeerConnection {
/**
- * @param {number} id
- * @param {Object} videoElement
+ * @param {!HTMLMediaElement} element - And 'audio' or 'video' element.
+ * @param {!Object} constraints - The constraints for the peer connection.
*/
- constructor(videoElement) {
+ constructor(element, constraints) {
this.localConnection = null;
this.remoteConnection = null;
- this.remoteView = videoElement;
+ this.remoteElement = element;
+ this.constraints = constraints;
}
start() {
return navigator.mediaDevices
- .getUserMedia({
- audio: true,
- video: {
- mandatory: {
- maxWidth: 300,
- minWidth: 300,
- }
- }
- }).then((stream) => {this.onGetUserMediaSuccess(stream)});
+ .getUserMedia(this.constraints)
+ .then((stream) => {
+ this.onGetUserMediaSuccess(stream)
+ });
};
onGetUserMediaSuccess(stream) {
@@ -81,7 +77,7 @@
this.onIceCandidate(this.localConnection, event);
};
this.remoteConnection.onaddstream = (e) => {
- this.remoteView.srcObject = e.stream;
+ this.remoteElement.srcObject = e.stream;
};
this.localConnection
@@ -114,7 +110,7 @@
constructor(runtimeSeconds, pausePlayIterationDelayMillis) {
this.runtimeSeconds = runtimeSeconds;
this.pausePlayIterationDelayMillis = pausePlayIterationDelayMillis;
- this.videoElements = [];
+ this.elements = [];
this.peerConnections = [];
this.feedTable = new FeedTable();
this.iteration = 0;
@@ -122,10 +118,20 @@
this.lastIterationTime;
}
- addPeerConnection() {
- const videoElement = this.feedTable.addNewCell();
- this.videoElements.push(videoElement);
- this.peerConnections.push(new PeerConnection(videoElement));
+ addPeerConnection(elementType) {
+ const element = this.feedTable.addNewCell(elementType);
+ const constraints = {audio: true};
+ if (elementType === 'video') {
+ constraints.video = {
+ width: {exact: 300}
+ };
+ } else if (elementType === 'audio') {
+ constraints.video = false;
+ } else {
+ throw new Error('elementType must be one of "audio" or "video"');
+ }
+ this.elements.push(element);
+ this.peerConnections.push(new PeerConnection(element, constraints));
}
startTest() {
@@ -141,7 +147,7 @@
pauseAndPlayLoop() {
this.iteration++;
- this.videoElements.forEach((feed) => {
+ this.elements.forEach((feed) => {
if (Math.random() >= 0.5) {
feed.play();
} else {
@@ -155,7 +161,7 @@
setTimeout(
() => {this.pauseAndPlayLoop()}, this.pausePlayIterationDelayMillis);
} else { // We're done. Pause all feeds.
- this.videoElements.forEach((feed) => {
+ this.elements.forEach((feed) => {
feed.pause();
});
}
@@ -182,11 +188,12 @@
let testRunner;
function startTest(
- runtimeSeconds, numPeerConnections, pausePlayIterationDelayMillis) {
+ runtimeSeconds, numPeerConnections, pausePlayIterationDelayMillis,
+ elementType) {
testRunner = new TestRunner(
runtimeSeconds, pausePlayIterationDelayMillis);
for (let i = 0; i < numPeerConnections; i++) {
- testRunner.addPeerConnection();
+ testRunner.addPeerConnection(elementType);
}
testRunner.startTest();
}
diff --git a/client/site_tests/webrtc_PausePlayPeerConnections/webrtc_PausePlayPeerConnections.py b/client/site_tests/webrtc_PausePlayPeerConnections/webrtc_PausePlayPeerConnections.py
index a8d7f22..09a630d 100644
--- a/client/site_tests/webrtc_PausePlayPeerConnections/webrtc_PausePlayPeerConnections.py
+++ b/client/site_tests/webrtc_PausePlayPeerConnections/webrtc_PausePlayPeerConnections.py
@@ -31,10 +31,11 @@
"""Tests many peerconnections randomly paused and played."""
version = 1
- def start_test(self, cr):
+ def start_test(self, cr, element_type):
"""Opens the WebRTC pause-play page.
@param cr: Autotest Chrome instance.
+ @param element_type: 'video' or 'audio'. String.
"""
cr.browser.platform.SetHTTPServerDirectories(self.bindir)
@@ -43,10 +44,11 @@
os.path.join(self.bindir, 'pause-play.html')))
self.tab.WaitForDocumentReadyStateToBeComplete()
self.tab.EvaluateJavaScript(
- "startTest(%d, %d, %d)" % (
+ "startTest(%d, %d, %d, %s)" % (
TEST_RUNTIME_SECONDS,
NUM_PEER_CONNECTIONS,
- PAUSE_PLAY_ITERATION_DELAY_MILLIS))
+ PAUSE_PLAY_ITERATION_DELAY_MILLIS,
+ element_type))
def wait_test_completed(self, timeout_secs):
"""Waits until the test is done.
@@ -65,12 +67,12 @@
desc='pause-play.html reports itself as finished')
@helper_logger.video_log_wrapper
- def run_once(self):
+ def run_once(self, element_type='video'):
"""Runs the test."""
with chrome.Chrome(extra_browser_args = EXTRA_BROWSER_ARGS + \
[helper_logger.chrome_vmodule_flag()],
init_network_controller = True) as cr:
- self.start_test(cr)
+ self.start_test(cr, element_type)
self.wait_test_completed(TIMEOUT)
self.print_result()
diff --git a/tko/perf_upload/perf_dashboard_config.json b/tko/perf_upload/perf_dashboard_config.json
index ee033c8..0a9837e 100644
--- a/tko/perf_upload/perf_dashboard_config.json
+++ b/tko/perf_upload/perf_dashboard_config.json
@@ -665,7 +665,11 @@
"master_name": "ChromeOSVideo"
},
{
- "autotest_name": "video_WebRtcPausePlayPeerConnections",
+ "autotest_name": "webrtc_PausePlayPeerConnections.video",
+ "master_name": "ChromeOSWebRtcVideo"
+ },
+ {
+ "autotest_name": "webrtc_PausePlayPeerConnections.audio",
"master_name": "ChromeOSWebRtcVideo"
},
{