Index: LayoutTests/webmidi/state-check-utils.js |
diff --git a/LayoutTests/webmidi/open_close.html b/LayoutTests/webmidi/state-check-utils.js |
similarity index 51% |
rename from LayoutTests/webmidi/open_close.html |
rename to LayoutTests/webmidi/state-check-utils.js |
index 39d70234d57bc0000e5b4794517122e7e3e7560c..8618771a8e069ff28ae0bdad09a58c942e0cea5b 100644 |
--- a/LayoutTests/webmidi/open_close.html |
+++ b/LayoutTests/webmidi/state-check-utils.js |
@@ -1,12 +1,3 @@ |
-<!DOCTYPE html> |
-<html> |
-<head> |
-<script src="../resources/js-test.js"></script> |
-</head> |
-<body> |
-<script> |
-description("Tests MIDIPort.open and MIDIPort.close."); |
- |
function checkStateTransition(options) { |
debug("Check state transition for " + options.method + " on " + |
options.initialconnection + " state."); |
@@ -30,6 +21,20 @@ function checkStateTransition(options) { |
debug("- check access handler."); |
checkHandler(e); |
}; |
+ if (options.method == "send") { |
+ port.send([]); |
+ } |
+ if (options.method == "midimessage") { |
yhirano
2015/04/02 02:15:10
[optional] How about naming this as "setonmidimess
Takashi Toyoshima
2015/04/02 04:03:20
Done.
|
+ port.onmidimessage = function() {}; |
+ } |
+ if (options.method == "send" || options.method == "midimessage") { |
+ // Following tests expect an implicit open finishes synchronously. |
+ // But it will be asynchronous in the future. |
+ debug("- check final state."); |
+ shouldBeEqualToString("port.connection", options.finalconnection); |
+ return Promise.resolve(); |
+ } |
+ // |method| is expected to be "open" or "close". |
return port[options.method]().then(function(p) { |
window.callbackport = p; |
debug("- check callback arguments."); |
@@ -44,48 +49,4 @@ function checkStateTransition(options) { |
}); |
} |
-function runTests(port) { |
- return Promise.resolve().then(checkStateTransition.bind(undefined, { |
- port: port, |
- method: "close", |
- initialconnection: "closed", |
- finalconnection: "closed", |
- })).then(checkStateTransition.bind(undefined, { |
- port: port, |
- method: "open", |
- initialconnection: "closed", |
- finalconnection: "open", |
- })).then(checkStateTransition.bind(undefined, { |
- port: port, |
- method: "open", |
- initialconnection: "open", |
- finalconnection: "open", |
- })).then(checkStateTransition.bind(undefined, { |
- port: port, |
- method: "close", |
- initialconnection: "open", |
- finalconnection: "closed", |
- })); |
-} |
- |
-function successAccessCallback(a) { |
- window.access = a; |
- testPassed("requestMIDIAccess() succeeded with access " + access + "."); |
- |
- runTests(access.inputs.values().next().value) |
- .then(finishJSTest, finishJSTest); |
-} |
- |
-function errorAccessCallback(error) { |
- testFailed("requestMIDIAccess() error callback should not be called when requesting basic access."); |
- finishJSTest(); |
-} |
- |
-window.jsTestIsAsync = true; |
- |
-// Test MIDIPort state transition by open() and close(). |
-navigator.requestMIDIAccess().then(successAccessCallback, errorAccessCallback); |
-</script> |
-</body> |
-</html> |