Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 navigator.requestMIDIAccess."); | 8 description("Tests navigator.requestMIDIAccess."); |
| 9 | 9 |
| 10 var access; | 10 var access; |
| 11 var input; | 11 var input; |
| 12 var output; | 12 var output; |
| 13 | 13 |
| 14 function checkInputMap(inputs) { | 14 function checkInputMap(inputs) { |
| 15 window.inputs = inputs; | 15 window.inputs = inputs; |
| 16 shouldBe("access.inputs.size", "1"); | 16 debug("for (var input of inputs.values())"); |
|
Takashi Toyoshima
2014/09/09 05:06:28
Are these debug() lines are intended changes?
yhirano
2014/09/09 05:14:46
I added "for (... of inputs.entries())" to disting
| |
| 17 for (var input of inputs) { | 17 for (var input of inputs.values()) { |
| 18 window.input = input; | 18 window.input = input; |
| 19 shouldBeEqualToString("input.id", "MockInputID"); | 19 shouldBeEqualToString("input.id", "MockInputID"); |
| 20 shouldBeEqualToString("input.manufacturer", "MockInputManufacturer"); | 20 shouldBeEqualToString("input.manufacturer", "MockInputManufacturer"); |
| 21 shouldBeEqualToString("input.name", "MockInputName"); | 21 shouldBeEqualToString("input.name", "MockInputName"); |
| 22 shouldBeEqualToString("input.version", "MockInputVersion"); | 22 shouldBeEqualToString("input.version", "MockInputVersion"); |
| 23 } | 23 } |
| 24 debug("for (var input of inputs.keys())"); | |
| 24 for (var key of inputs.keys()) { | 25 for (var key of inputs.keys()) { |
| 25 window.inputKey = key; | 26 window.inputKey = key; |
| 26 shouldBeEqualToString("inputKey", "MockInputID"); | 27 shouldBeEqualToString("inputKey", "MockInputID"); |
| 27 } | 28 } |
| 29 debug("for (var input of inputs.entries())"); | |
| 28 for (var entry of inputs.entries()) { | 30 for (var entry of inputs.entries()) { |
| 29 window.entry = entry; | 31 window.entry = entry; |
| 30 shouldBe("entry[0]", "inputKey"); | 32 shouldBe("entry[0]", "inputKey"); |
| 31 shouldBe("entry[1]", "input"); | 33 shouldBe("entry[1]", "input"); |
| 32 } | 34 } |
| 33 for (var input of inputs.values()) { | 35 debug("for (var input of inputs)"); |
| 34 window.inputValue = input; | 36 for (var entry of inputs) { |
| 35 shouldBe("inputValue", "input"); | 37 window.entry = entry; |
| 38 shouldBe("entry[0]", "inputKey"); | |
| 39 shouldBe("entry[1]", "input"); | |
| 36 } | 40 } |
| 37 shouldBeTrue("inputs.has('MockInputID')"); | 41 shouldBeTrue("inputs.has('MockInputID')"); |
| 38 shouldBeFalse("inputs.has('MockOutputID')"); | 42 shouldBeFalse("inputs.has('MockOutputID')"); |
| 39 shouldBe("inputs.get('MockInputID')", "input"); | 43 shouldBe("inputs.get('MockInputID')", "input"); |
| 40 shouldBeUndefined("inputs.get('MockOutputID')"); | 44 shouldBeUndefined("inputs.get('MockOutputID')"); |
| 41 } | 45 } |
| 42 | 46 |
| 43 function checkOutputMap(outputs) { | 47 function checkOutputMap(outputs) { |
| 44 window.outputs = outputs; | 48 window.outputs = outputs; |
| 49 debug("for (var output of outputs.values())"); | |
| 45 for (var output of outputs.values()) { | 50 for (var output of outputs.values()) { |
| 46 window.output = output; | 51 window.output = output; |
| 47 shouldBeEqualToString("output.id", "MockOutputID"); | 52 shouldBeEqualToString("output.id", "MockOutputID"); |
| 48 shouldBeEqualToString("output.manufacturer", "MockOutputManufacturer"); | 53 shouldBeEqualToString("output.manufacturer", "MockOutputManufacturer"); |
| 49 shouldBeEqualToString("output.name", "MockOutputName"); | 54 shouldBeEqualToString("output.name", "MockOutputName"); |
| 50 shouldBeEqualToString("output.version", "MockOutputVersion"); | 55 shouldBeEqualToString("output.version", "MockOutputVersion"); |
| 51 } | 56 } |
| 57 debug("for (var output of outputs.keys())"); | |
| 52 for (var key of outputs.keys()) { | 58 for (var key of outputs.keys()) { |
| 53 window.outputKey = key; | 59 window.outputKey = key; |
| 54 shouldBeEqualToString("outputKey", "MockOutputID"); | 60 shouldBeEqualToString("outputKey", "MockOutputID"); |
| 55 } | 61 } |
| 62 debug("for (var output of outputs.entries())"); | |
| 56 for (var entry of outputs.entries()) { | 63 for (var entry of outputs.entries()) { |
| 57 window.entry = entry; | 64 window.entry = entry; |
| 58 shouldBe("entry[0]", "outputKey"); | 65 shouldBe("entry[0]", "outputKey"); |
| 59 shouldBe("entry[1]", "output"); | 66 shouldBe("entry[1]", "output"); |
| 60 } | 67 } |
| 61 for (var output of outputs.values()) { | 68 debug("for (var output of outputs)"); |
| 62 window.outputValue = output; | 69 for (var entry of outputs) { |
| 63 shouldBe("outputValue", "output"); | 70 window.entry = entry; |
| 71 shouldBe("entry[0]", "outputKey"); | |
| 72 shouldBe("entry[1]", "output"); | |
| 64 } | 73 } |
| 65 shouldBeTrue("outputs.has('MockOutputID')"); | 74 shouldBeTrue("outputs.has('MockOutputID')"); |
| 66 shouldBeFalse("outputs.has('MockInputID')"); | 75 shouldBeFalse("outputs.has('MockInputID')"); |
| 67 shouldBe("outputs.get('MockOutputID')", "output"); | 76 shouldBe("outputs.get('MockOutputID')", "output"); |
| 68 shouldBeUndefined("outputs.get('MockInputID')"); | 77 shouldBeUndefined("outputs.get('MockInputID')"); |
| 69 } | 78 } |
| 70 | 79 |
| 71 function successCallback1(a) { | 80 function successCallback1(a) { |
| 72 access = a; | 81 access = a; |
| 73 | 82 |
| 74 testPassed("requestMIDIAccess() succeeded with access " + access + "."); | 83 testPassed("requestMIDIAccess() succeeded with access " + access + "."); |
| 75 | 84 |
| 76 // Validate the values of the attributes on the access. | 85 // Validate the values of the attributes on the access. |
| 77 shouldBeDefined("access.sysexEnabled"); | 86 shouldBeDefined("access.sysexEnabled"); |
| 78 shouldBeFalse("access.sysexEnabled"); | 87 shouldBeFalse("access.sysexEnabled"); |
| 79 | 88 shouldBe("access.inputs.size", "1"); |
| 89 shouldBe("access.outputs.size", "1"); | |
| 80 checkInputMap(access.inputs); | 90 checkInputMap(access.inputs); |
| 81 checkOutputMap(access.outputs); | 91 checkOutputMap(access.outputs); |
| 82 | 92 |
| 83 window.output = access.outputs[Symbol.iterator]().next().value; | 93 window.output = access.outputs.values().next().value; |
| 84 // Test sending of MIDI data with a Uint8Array. | 94 // Test sending of MIDI data with a Uint8Array. |
| 85 var typedArrayData = new Uint8Array([0x90, 0x45, 0x7f]); | 95 var typedArrayData = new Uint8Array([0x90, 0x45, 0x7f]); |
| 86 output.send(typedArrayData); | 96 output.send(typedArrayData); |
| 87 | 97 |
| 88 // Test sending of MIDI data with a regular Array. | 98 // Test sending of MIDI data with a regular Array. |
| 89 output.send([0x90, 0x45, 0x7f]); | 99 output.send([0x90, 0x45, 0x7f]); |
| 90 testPassed("a note on message is sent without timestamp"); | 100 testPassed("a note on message is sent without timestamp"); |
| 91 | 101 |
| 92 // Test sending of MIDI data with a regular Array giving an explicit timesta mp. | 102 // Test sending of MIDI data with a regular Array giving an explicit timesta mp. |
| 93 output.send([0x90, 0x45, 0x7f], performance.now()); | 103 output.send([0x90, 0x45, 0x7f], performance.now()); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 119 } | 129 } |
| 120 | 130 |
| 121 window.jsTestIsAsync = true; | 131 window.jsTestIsAsync = true; |
| 122 | 132 |
| 123 // Test basic access, with no System Exclusive. | 133 // Test basic access, with no System Exclusive. |
| 124 navigator.requestMIDIAccess().then(successCallback1, errorCallback1); | 134 navigator.requestMIDIAccess().then(successCallback1, errorCallback1); |
| 125 | 135 |
| 126 </script> | 136 </script> |
| 127 </body> | 137 </body> |
| 128 </html> | 138 </html> |
| OLD | NEW |