Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * TODO(garykac): Create interface for SignalStrategy. | 7 * TODO(garykac): Create interface for SignalStrategy. |
| 8 * @suppress {checkTypes|checkVars|reportUnknownTypes|visibility} | 8 * @suppress {accessControls|checkTypes|checkVars|reportUnknownTypes|visibility} |
|
Jamie
2015/03/13 17:56:17
Do you need to suppress accessControls if you're u
John Williams
2015/03/13 19:30:29
Nope, meant to remove that.
| |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 (function() { | 11 (function() { |
| 12 | 12 |
| 13 'use strict'; | 13 'use strict'; |
| 14 | 14 |
| 15 /** @type {(sinon.Spy|function(remoting.SignalStrategy.State))} */ | 15 /** @type {(sinon.Spy|function(remoting.SignalStrategy.State))} */ |
| 16 var onStateChange = null; | 16 var onStateChange = null; |
| 17 | 17 |
| 18 /** @type {(sinon.Spy|function(Element):void)} */ | 18 /** @type {(sinon.Spy|function(Element):void)} */ |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 sinon.assert.calledWith(onStateChange, state); | 118 sinon.assert.calledWith(onStateChange, state); |
| 119 }); | 119 }); |
| 120 } | 120 } |
| 121 ); | 121 ); |
| 122 | 122 |
| 123 test('blocked', | 123 test('blocked', |
| 124 function() { | 124 function() { |
| 125 fakeXhrs[0].respond(400); | 125 fakeXhrs[0].respond(400); |
| 126 sinon.assert.calledWith(onStateChange, | 126 sinon.assert.calledWith(onStateChange, |
| 127 remoting.SignalStrategy.State.FAILED); | 127 remoting.SignalStrategy.State.FAILED); |
| 128 equal(checker.getError().tag, remoting.Error.Tag.NOT_AUTHORIZED); | 128 ok(checker.getError().hasTag(remoting.Error.Tag.NOT_AUTHORIZED)); |
| 129 onStateChange.reset(); | 129 onStateChange.reset(); |
| 130 | 130 |
| 131 [ | 131 [ |
| 132 remoting.SignalStrategy.State.CONNECTING, | 132 remoting.SignalStrategy.State.CONNECTING, |
| 133 remoting.SignalStrategy.State.HANDSHAKE, | 133 remoting.SignalStrategy.State.HANDSHAKE, |
| 134 remoting.SignalStrategy.State.CONNECTED | 134 remoting.SignalStrategy.State.CONNECTED |
| 135 ].forEach(function(state) { | 135 ].forEach(function(state) { |
| 136 signalStrategy.setStateForTesting(state); | 136 signalStrategy.setStateForTesting(state); |
| 137 sinon.assert.notCalled(onStateChange); | 137 sinon.assert.notCalled(onStateChange); |
| 138 equal(checker.getState(), remoting.SignalStrategy.State.FAILED); | 138 equal(checker.getState(), remoting.SignalStrategy.State.FAILED); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 156 // signal strategy has connected. | 156 // signal strategy has connected. |
| 157 signalStrategy.setStateForTesting(remoting.SignalStrategy.State.CONNECTED); | 157 signalStrategy.setStateForTesting(remoting.SignalStrategy.State.CONNECTED); |
| 158 sinon.assert.notCalled(onStateChange); | 158 sinon.assert.notCalled(onStateChange); |
| 159 equal(checker.getState(), remoting.SignalStrategy.State.HANDSHAKE); | 159 equal(checker.getState(), remoting.SignalStrategy.State.HANDSHAKE); |
| 160 | 160 |
| 161 // Verify that DnsBlackholeChecker goes to FAILED state after it gets the | 161 // Verify that DnsBlackholeChecker goes to FAILED state after it gets the |
| 162 // blocked HTTP response. | 162 // blocked HTTP response. |
| 163 fakeXhrs[0].respond(400); | 163 fakeXhrs[0].respond(400); |
| 164 sinon.assert.calledWith(onStateChange, | 164 sinon.assert.calledWith(onStateChange, |
| 165 remoting.SignalStrategy.State.FAILED); | 165 remoting.SignalStrategy.State.FAILED); |
| 166 equal(checker.getError().tag, remoting.Error.Tag.NOT_AUTHORIZED); | 166 ok(checker.getError().hasTag(remoting.Error.Tag.NOT_AUTHORIZED)); |
| 167 } | 167 } |
| 168 ); | 168 ); |
| 169 | 169 |
| 170 })(); | 170 })(); |
| OLD | NEW |