Commit 50136d7e authored by shadi@chromium.org's avatar shadi@chromium.org

Enable MSE perf tests.

Better handling of errors and adding required command line args for gesture enabled devices.

BUG=330910, 329691

Review URL: https://codereview.chromium.org/131123008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245358 0039d316-1c4b-4281-b951-d872f2087c98
parent 1e5da63d
......@@ -13,8 +13,8 @@ from measurements import media
class MSEMeasurement(page_measurement.PageMeasurement):
def MeasurePage(self, page, tab, results):
media_metric = tab.EvaluateJavaScript('window.__testMetrics')
trace = media_metric['id']
metrics = media_metric['metrics']
trace = media_metric['id'] if 'id' in media_metric else None
metrics = media_metric['metrics'] if 'metrics' in media_metric else []
for m in metrics:
if isinstance(metrics[m], list):
values = [float(v) for v in metrics[m]]
......@@ -70,12 +70,11 @@ class MediaSourceExtensions(test.Test):
test = media.Media
# Disable MSE media-tests on Android and linux: crbug/329691
# Disable MSE tests on windows 8 crbug.com/330910
enabled = (not sys.platform.startswith('linux') and
not sys.platform.startswith('win'))
test = MSEMeasurement
page_set = 'page_sets/mse_cases.json'
def CustomizeBrowserOptions(self, options):
# Needed to allow XHR requests to return stream objects.
options.AppendExtraBrowserArgs(
'--enable-experimental-web-platform-features')
['--enable-experimental-web-platform-features',
'--disable-gesture-requirement-for-media-playback'])
......@@ -35,13 +35,17 @@
testParams = {};
testParams.testType = queryParameters["testType"] || "AV";
testParams.useAppendStream = (queryParameters["useAppendStream"] == "true");
testParams.doNotWaitForBodyOnLoad = (queryParameters["doNotWaitForBodyOnLoad"] == "true");
testParams.doNotWaitForBodyOnLoad =
(queryParameters["doNotWaitForBodyOnLoad"] == "true");
testParams.startOffset = 0;
testParams.appendSize = parseInt(queryParameters["appendSize"] || "65536");
testParams.graphDuration = parseInt(queryParameters["graphDuration"] || "1000");
testParams.graphDuration =
parseInt(queryParameters["graphDuration"] || "1000");
}
function plotTimestamps(timestamps, graphDuration, element) {
if (!timestamps)
return;
var c = document.getElementById('c');
var ctx = c.getContext('2d');
......@@ -80,7 +84,11 @@
}
}
bars.push({label: 'Post Append Delay', start: maxAppendEndTime, end: timestamps.testEndTime, color: '#B0B0B0' });
bars.push({
label: 'Post Append Delay',
start: maxAppendEndTime,
end: timestamps.testEndTime,
color: '#B0B0B0' });
var minTimestamp = Number.MAX_VALUE;
for (var i = 0; i < bars.length; ++i) {
......@@ -120,7 +128,8 @@
var statsMarkup = "Test passed<br><table>";
for (var i in stats) {
statsMarkup += "<tr><td style=\"text-align:right\">" + i + ":</td><td>" + stats[i].toFixed(3) + " ms</td>";
statsMarkup += "<tr><td style=\"text-align:right\">" + i + ":</td><td>" +
stats[i].toFixed(3) + " ms</td>";
}
statsMarkup += "</table>";
statsDiv.innerHTML = statsMarkup;
......@@ -156,8 +165,10 @@
}
}
document.getElementById("useAppendStream").checked = testParams.useAppendStream;
document.getElementById("doNotWaitForBodyOnLoad").checked = testParams.doNotWaitForBodyOnLoad;
document.getElementById("useAppendStream").checked =
testParams.useAppendStream;
document.getElementById("doNotWaitForBodyOnLoad").checked =
testParams.doNotWaitForBodyOnLoad;
document.getElementById("appendSize").value = testParams.appendSize;
document.getElementById("graphDuration").value = testParams.graphDuration;
}
......@@ -255,7 +266,7 @@
(this.startOffset + this.appendSize - 1));
this.xhr.responseType = 'stream';
if (this.xhr.responseType != 'stream') {
throw "XHR does not support 'stream' responses.";
EndTest("XHR does not support 'stream' responses.");
}
this.xhr.send();
......@@ -421,12 +432,12 @@
if (testDone)
return;
console.log('Test timed out.');
testDone = true;
window.clearInterval(listener);
mediaElement.pause();
doneCallback(null);
EndTest("Test timed out.");
}, 10000);
mediaSourceOpenStartTime = getPerfTimestamp();
......@@ -446,31 +457,50 @@
var appenders = [];
if (useAppendStream && !window.MediaSource)
throw "Can't use appendStream() because the unprefixed MediaSource object is not present.";
if (testParams.useAppendStream && !window.MediaSource)
EndTest("Can't use appendStream() because the unprefixed MediaSource " +
"object is not present.");
var Appender = testParams.useAppendStream ? StreamAppender : BufferAppender;
if (testParams.testType.indexOf("A") != -1) {
appenders.push(new Appender("audio/mp4; codecs=\"mp4a.40.2\"", "audio.mp4", "a", testParams.startOffset, testParams.appendSize));
appenders.push(
new Appender("audio/mp4; codecs=\"mp4a.40.2\"",
"audio.mp4",
"a",
testParams.startOffset,
testParams.appendSize));
}
if (testParams.testType.indexOf("V") != -1) {
appenders.push(new Appender("video/mp4; codecs=\"avc1.640028\"", "video.mp4", "v", testParams.startOffset, testParams.appendSize));
appenders.push(
new Appender("video/mp4; codecs=\"avc1.640028\"",
"video.mp4",
"v",
testParams.startOffset,
testParams.appendSize));
}
var video = document.getElementById('v');
var video = document.getElementById("v");
video.addEventListener("error", function(e) {
console.log("video error!");
EndTest("Video error: " + video.error);
});
video.id = getTestID();
runAppendTest(video, appenders, function(stats, timestamps) {
displayResults(stats);
plotTimestamps(timestamps, testParams.graphDuration, video);
window.__testDone = true;
EndTest("Call back call done.");
});
}
function EndTest(msg) {
console.log("Ending test: " + msg);
window.__testDone = true;
}
function getTestID() {
console.log("setting test ID")
console.log(testParams.doNotWaitForBodyOnLoad)
var id = testParams.testType;
if (testParams.useAppendStream)
id += "_stream"
......@@ -494,5 +524,5 @@
window["setupTest"] = setupTest;
window.__testDone = false;
window.__testMetrics = null;
window.__testMetrics = {};
})();
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