Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(486)

Unified Diff: third_party/WebKit/LayoutTests/webaudio/OfflineAudioContext/onstatechange.html

Issue 2680033002: Convert OfflineAudioContext tests to testharness (Closed)
Patch Set: Reindent. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/webaudio/OfflineAudioContext/onstatechange.html
diff --git a/third_party/WebKit/LayoutTests/webaudio/OfflineAudioContext/onstatechange.html b/third_party/WebKit/LayoutTests/webaudio/OfflineAudioContext/onstatechange.html
index 4e20b77ff3d7ca1470146d98d4606b16ad2cf85b..0f88289c59e37e0321558672259314eeba0bb041 100644
--- a/third_party/WebKit/LayoutTests/webaudio/OfflineAudioContext/onstatechange.html
+++ b/third_party/WebKit/LayoutTests/webaudio/OfflineAudioContext/onstatechange.html
@@ -2,17 +2,15 @@
<html>
<head>
<title>Test statechange event</title>
- <script src="../../resources/js-test.js"></script>
+ <script src="../../resources/testharness.js"></script>
+ <script src="../../resources/testharnessreport.js"></script>
<script src="../resources/audit-util.js"/></script>
- <script src="../resources/audio-testing.js"/></script>
+ <script src="../resources/audit.js"/></script>
</head>
<body>
<script>
- description("Test statechange event is properly signaled")
-
- window.jsTestIsAsync = true;
-
+ var audit = Audit.createTaskRunner();
var secondsToRender = 2;
var sampleRate = 48000;
@@ -20,30 +18,35 @@
var context;
var contextState;
- function checkStateChange (e) {
+ function checkStateChange (e, should) {
contextState = e.currentTarget.state;
switch (stateChangeCount) {
case 0:
- shouldBeEqualToString("contextState", "running");
+ should(contextState, "context.state")
+ .beEqualTo("running");
break;
case 1:
- shouldBeEqualToString("contextState", "closed");
+ should(contextState, "context.state")
+ .beEqualTo("closed");
break;
default:
- testFailed("Expected only two state changes but got " + stateChangeCount);
+ should(stateChangeCount, "Number of state changes")
+ .beLessThanOrEqualTo(2)
}
++stateChangeCount;
}
- function finalCheck() {
+ function finalCheck(should) {
// Final check that we got the right number of state changes and the correct final state.
- shouldBeEqualToNumber("stateChangeCount", 2);
- shouldBeEqualToString("context.state", "closed");
- finishJSTest();
+ should(stateChangeCount, "stateChangeCount")
+ .beEqualTo(2);
+ should(context.state, "context.state")
+ .beEqualTo("closed");
}
- function runTest() {
+ audit.define('test', (task, should) => {
+ task.describe('Signaling of statechange event');
// Create an offline context with a source passing through a convolver. The convolver is
// just to waste some time.
context = new OfflineAudioContext(1, secondsToRender * sampleRate, sampleRate);
@@ -60,20 +63,22 @@
source.start();
- context.onstatechange = checkStateChange;
+ context.onstatechange = (event) => checkStateChange(event, should);
- context.startRendering().then(function () {
- testPassed("context finished rendering")
- });
+ should(context.startRendering(), "Context rendering")
+ .beResolved();
// Don't want to set an oncomplete for the context and don't want to use the promise because
// the order of the state change event and resolving the promise is not specified. Thus,
// just wait for a bit and then finish the test. We assume the offline context runs faster
// than realtime.
- setTimeout(finalCheck, secondsToRender * 1000);
- }
+ setTimeout(() => {
+ finalCheck(should);
+ task.done();
+ }, secondsToRender * 1000);
+ });
- runTest();
+ audit.run();
</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698