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

Unified Diff: LayoutTests/webmidi/open_close.html

Issue 962523005: Web MIDI: add open() and close() to MIDIPort (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: cast and win build fix Created 5 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
« no previous file with comments | « no previous file | LayoutTests/webmidi/open_close-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/webmidi/open_close.html
diff --git a/LayoutTests/webmidi/open_close.html b/LayoutTests/webmidi/open_close.html
new file mode 100644
index 0000000000000000000000000000000000000000..e369ab88d2bd769b89bfe4e92b7e2f34ea4b9eb7
--- /dev/null
+++ b/LayoutTests/webmidi/open_close.html
@@ -0,0 +1,97 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../resources/js-test.js"></script>
+</head>
+<body>
+<script>
+description("Tests MIDIPort.open and MIDIPort.close.");
+
+function connectedPortCallback(port) {
+ window.connectedPort = port;
+ shouldBeEqualToString("connectedPort.state", "connected");
+}
+
+function openedPortCallback(port) {
+ window.openedPort = port;
+ shouldBeEqualToString("openedPort.state", "opened");
+}
+
+function errorPortCallback(error) {
+ testFailed("open() or close() error callback should not be called here.");
+ finishJSTest();
+}
+
+function connectedPortHandler(e) {
+ window.eventPort = e.port;
+ shouldBeEqualToString("eventPort.state", "connected");
+}
+
+function openedPortHandler(e) {
+ window.eventPort = e.port;
+ shouldBeEqualToString("eventPort.state", "opened");
+}
+
+function errorPortHandler(e) {
+ testFailed("onstatechange handler should not be called here.");
+ finishJSTest();
+}
+
+function finishOnConnected(port) {
+ window.port = port;
+ shouldBeEqualToString("port.state", "connected");
+ finishJSTest();
+}
+
+function checkCloseOnOpened(port) {
+ window.port = port;
+ shouldBeEqualToString("port.state", "opened");
+ port.onstatechange = connectedPortHandler;
+ port.close().then(finishOnConnected, errorPortCallback);
+}
+
+function checkOpenOnOpened(port) {
+ window.port = port;
+ shouldBeEqualToString("port.state", "opened");
+ port.onstatechange = errorPortHandler;
+ port.open().then(checkCloseOnOpened, errorPortCallback);
+}
+
+function checkOpenOnConnected(port) {
+ window.port = port;
+ shouldBeEqualToString("port.state", "connected");
+ port.onstatechange = openedPortHandler;
+ port.open().then(checkOpenOnOpened, errorPortCallback);
+}
+
+function checkCloseOnConnected(port) {
+ window.port = port;
+ shouldBeEqualToString("port.state", "connected");
+ port.onstatechange = errorPortHandler;
+ port.close().then(checkOpenOnConnected, errorPortCallback);
+}
+
+function checkMIDIPortStateTransition(port) {
+ checkCloseOnConnected(port);
yhirano 2015/03/02 05:34:32 How about listing tests here? return Promise.reso
Takashi Toyoshima 2015/03/02 15:44:44 that's nice idea, and I went more aggressively in
+}
+
+function successAccessCallback(a) {
+ window.access = a;
+ testPassed("requestMIDIAccess() succeeded with access " + access + ".");
+
+ checkMIDIPortStateTransition(access.inputs.values().next().value);
yhirano 2015/03/02 05:34:32 If you return a promise from checkMIDIPortStateTra
Takashi Toyoshima 2015/03/02 15:44:44 Done.
+}
+
+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>
« no previous file with comments | « no previous file | LayoutTests/webmidi/open_close-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698