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

Side by Side Diff: LayoutTests/webmidi/open_close.html

Issue 1043863002: Web MIDI: final IDL updates to conform the latest WD for shipping (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: TODO: ActiveDOMObject Created 5 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../resources/js-test.js"></script> 4 <script src="../resources/js-test.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <script> 7 <script>
8 description("Tests MIDIPort.open and MIDIPort.close."); 8 description("Tests MIDIPort.open and MIDIPort.close.");
9 9
10 function checkStateTransition(options) { 10 function checkStateTransition(options) {
11 debug("Check state transition for " + options.method + " on " + 11 debug("Check state transition for " + options.method + " on " +
12 options.initialstate + " state."); 12 options.initialconnection + " state.");
13 debug("- check initial state."); 13 debug("- check initial state.");
14 window.port = options.port; 14 window.port = options.port;
15 shouldBeEqualToString("port.state", options.initialstate); 15 shouldBeEqualToString("port.connection", options.initialconnection);
16 port.onstatechange = function(e) { 16 port.onstatechange = function(e) {
17 debug("- check handler port."); 17 debug("- check handler port.");
18 window.eventport = e.port; 18 window.eventport = e.port;
19 testPassed("handler is called with port " + eventport + "."); 19 testPassed("handler is called with port " + eventport + ".");
20 if (options.initialstate == options.finalstate) { 20 if (options.initialconnection == options.finalconnection) {
21 testFailed("onstatechange handler should not be called here."); 21 testFailed("onstatechange handler should not be called here.");
22 } 22 }
23 shouldBeEqualToString("eventport.id", options.port.id); 23 shouldBeEqualToString("eventport.id", options.port.id);
24 shouldBeEqualToString("eventport.state", options.finalstate); 24 shouldBeEqualToString("eventport.connection", options.finalconnection);
25 }; 25 };
26 return port[options.method]().then(function(p) { 26 return port[options.method]().then(function(p) {
27 window.callbackport = p; 27 window.callbackport = p;
28 debug("- check callback arguments."); 28 debug("- check callback arguments.");
29 testPassed("callback is called with port " + callbackport + "."); 29 testPassed("callback is called with port " + callbackport + ".");
30 shouldBeEqualToString("callbackport.id", options.port.id); 30 shouldBeEqualToString("callbackport.id", options.port.id);
31 shouldBeEqualToString("callbackport.state", options.finalstate); 31 shouldBeEqualToString("callbackport.connection", options.finalconnection );
32 debug("- check final state."); 32 debug("- check final state.");
33 shouldBeEqualToString("port.state", options.finalstate); 33 shouldBeEqualToString("port.connection", options.finalconnection);
34 }, function(e) { 34 }, function(e) {
35 testFailed("error callback should not be called here."); 35 testFailed("error callback should not be called here.");
36 throw e; 36 throw e;
37 }); 37 });
38 } 38 }
39 39
40 function runTests(port) { 40 function runTests(port) {
41 return Promise.resolve().then(checkStateTransition.bind(undefined, { 41 return Promise.resolve().then(checkStateTransition.bind(undefined, {
42 port: port, 42 port: port,
43 method: "close", 43 method: "close",
44 initialstate: "connected", 44 initialconnection: "closed",
45 finalstate: "connected", 45 finalconnection: "closed",
46 })).then(checkStateTransition.bind(undefined, { 46 })).then(checkStateTransition.bind(undefined, {
47 port: port, 47 port: port,
48 method: "open", 48 method: "open",
49 initialstate: "connected", 49 initialconnection: "closed",
50 finalstate: "opened", 50 finalconnection: "open",
51 })).then(checkStateTransition.bind(undefined, { 51 })).then(checkStateTransition.bind(undefined, {
52 port: port, 52 port: port,
53 method: "open", 53 method: "open",
54 initialstate: "opened", 54 initialconnection: "open",
55 finalstate: "opened", 55 finalconnection: "open",
56 })).then(checkStateTransition.bind(undefined, { 56 })).then(checkStateTransition.bind(undefined, {
57 port: port, 57 port: port,
58 method: "close", 58 method: "close",
59 initialstate: "opened", 59 initialconnection: "open",
60 finalstate: "connected", 60 finalconnection: "closed",
61 })); 61 }));
62 } 62 }
63 63
64 function successAccessCallback(a) { 64 function successAccessCallback(a) {
65 window.access = a; 65 window.access = a;
66 testPassed("requestMIDIAccess() succeeded with access " + access + "."); 66 testPassed("requestMIDIAccess() succeeded with access " + access + ".");
67 67
68 runTests(access.inputs.values().next().value) 68 runTests(access.inputs.values().next().value)
69 .then(finishJSTest, finishJSTest); 69 .then(finishJSTest, finishJSTest);
70 } 70 }
71 71
72 function errorAccessCallback(error) { 72 function errorAccessCallback(error) {
73 testFailed("requestMIDIAccess() error callback should not be called when req uesting basic access."); 73 testFailed("requestMIDIAccess() error callback should not be called when req uesting basic access.");
74 finishJSTest(); 74 finishJSTest();
75 } 75 }
76 76
77 window.jsTestIsAsync = true; 77 window.jsTestIsAsync = true;
78 78
79 // Test MIDIPort state transition by open() and close(). 79 // Test MIDIPort state transition by open() and close().
80 navigator.requestMIDIAccess().then(successAccessCallback, errorAccessCallback); 80 navigator.requestMIDIAccess().then(successAccessCallback, errorAccessCallback);
81 81
82 </script> 82 </script>
83 </body> 83 </body>
84 </html> 84 </html>
OLDNEW
« no previous file with comments | « LayoutTests/webexposed/global-interface-listing-expected.txt ('k') | LayoutTests/webmidi/open_close-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698