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

Unified Diff: remoting/webapp/crd/js/dns_blackhole_checker_unittest.js

Issue 1133913002: [Chromoting] Move shared webapp JS files from crd/js -> base/js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 | « remoting/webapp/crd/js/dns_blackhole_checker.js ('k') | remoting/webapp/crd/js/error.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/crd/js/dns_blackhole_checker_unittest.js
diff --git a/remoting/webapp/crd/js/dns_blackhole_checker_unittest.js b/remoting/webapp/crd/js/dns_blackhole_checker_unittest.js
deleted file mode 100644
index 46abdd4f964b8ff1f0794a24949b7ebd6339cba6..0000000000000000000000000000000000000000
--- a/remoting/webapp/crd/js/dns_blackhole_checker_unittest.js
+++ /dev/null
@@ -1,197 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-/**
- * @fileoverview
- * TODO(garykac): Create interface for SignalStrategy.
- * @suppress {checkTypes|checkVars|reportUnknownTypes|visibility}
- */
-
-(function() {
-
-'use strict';
-
-/** @type {(sinon.Spy|function(remoting.SignalStrategy.State))} */
-var onStateChange = null;
-
-/** @type {(sinon.Spy|function(Element):void)} */
-var onIncomingStanzaCallback = null;
-
-/** @type {remoting.DnsBlackholeChecker} */
-var checker = null;
-
-/** @type {remoting.MockSignalStrategy} */
-var signalStrategy = null;
-
-/** @type {sinon.FakeXhr} */
-var fakeXhr = null;
-
-QUnit.module('dns_blackhole_checker', {
- beforeEach: function(assert) {
- sinon.useFakeXMLHttpRequest().onCreate = function(xhr) {
- QUnit.equal(fakeXhr, null, 'exactly one XHR is issued');
- fakeXhr = xhr;
- };
-
- onStateChange = sinon.spy();
- onIncomingStanzaCallback = sinon.spy();
- signalStrategy = new remoting.MockSignalStrategy();
- sinon.stub(signalStrategy, 'connect', base.doNothing);
- checker = new remoting.DnsBlackholeChecker(signalStrategy);
-
- checker.setStateChangedCallback(onStateChange);
- checker.setIncomingStanzaCallback(onIncomingStanzaCallback);
-
- sinon.assert.notCalled(onStateChange);
- sinon.assert.notCalled(signalStrategy.connect);
- checker.connect('server', 'username', 'authToken');
- sinon.assert.calledWith(signalStrategy.connect, 'server', 'username',
- 'authToken');
-
- assert.equal(
- fakeXhr.url, remoting.DnsBlackholeChecker.URL_TO_REQUEST_,
- 'the correct URL is requested');
- },
- afterEach: function() {
- base.dispose(checker);
- sinon.assert.calledWith(onStateChange,
- remoting.SignalStrategy.State.CLOSED);
-
- onStateChange = null;
- onIncomingStanzaCallback = null;
- checker = null;
- fakeXhr = null;
- }
-});
-
-QUnit.test('success',
- function(assert) {
- function checkState(state) {
- signalStrategy.setStateForTesting(state);
- sinon.assert.calledWith(onStateChange, state);
- assert.equal(checker.getState(), state);
- }
-
- return base.SpyPromise.run(function() {
- fakeXhr.respond(200);
- }).then(function() {
- sinon.assert.notCalled(onStateChange);
- checkState(remoting.SignalStrategy.State.CONNECTING);
- checkState(remoting.SignalStrategy.State.HANDSHAKE);
- checkState(remoting.SignalStrategy.State.CONNECTED);
- });
- });
-
-QUnit.test('http response after connected',
- function(assert) {
- function checkState(state) {
- signalStrategy.setStateForTesting(state);
- sinon.assert.calledWith(onStateChange, state);
- assert.equal(checker.getState(), state);
- }
-
- checkState(remoting.SignalStrategy.State.CONNECTING);
- checkState(remoting.SignalStrategy.State.HANDSHAKE);
- onStateChange.reset();
-
- // Verify that DnsBlackholeChecker stays in HANDSHAKE state even if the
- // signal strategy has connected.
- return base.SpyPromise.run(function() {
- signalStrategy.setStateForTesting(
- remoting.SignalStrategy.State.CONNECTED);
- }).then(function() {
- sinon.assert.notCalled(onStateChange);
- assert.equal(checker.getState(), remoting.SignalStrategy.State.HANDSHAKE);
-
- // Verify that DnsBlackholeChecker goes to CONNECTED state after the
- // the HTTP request has succeeded.
- return base.SpyPromise.run(function() {
- fakeXhr.respond(200);
- });
- }).then(function() {
- sinon.assert.calledWith(onStateChange,
- remoting.SignalStrategy.State.CONNECTED);
- });
- });
-
-QUnit.test('connect failed',
- function(assert) {
- function checkState(state) {
- signalStrategy.setStateForTesting(state);
- sinon.assert.calledWith(onStateChange, state);
- };
-
- return base.SpyPromise.run(function() {
- fakeXhr.respond(200);
- }).then(function() {
- sinon.assert.notCalled(onStateChange);
- checkState(remoting.SignalStrategy.State.CONNECTING);
- checkState(remoting.SignalStrategy.State.FAILED);
- });
- });
-
-QUnit.test('blocked',
- function(assert) {
- function checkState(state) {
- assert.equal(checker.getError().getTag(),
- remoting.Error.Tag.NOT_AUTHORIZED);
- onStateChange.reset();
- signalStrategy.setStateForTesting(state);
- sinon.assert.notCalled(onStateChange);
- assert.equal(checker.getState(),
- checker.getState(),
- remoting.SignalStrategy.State.FAILED,
- 'checker state is still FAILED');
- };
-
- return base.SpyPromise.run(function() {
- fakeXhr.respond(400);
- }).then(function() {
- sinon.assert.calledWith(
- onStateChange, remoting.SignalStrategy.State.FAILED);
- assert.equal(
- checker.getError().getTag(),
- remoting.Error.Tag.NOT_AUTHORIZED,
- 'checker error is NOT_AUTHORIZED');
- checkState(remoting.SignalStrategy.State.CONNECTING);
- checkState(remoting.SignalStrategy.State.HANDSHAKE);
- checkState(remoting.SignalStrategy.State.FAILED);
- });
- });
-
-QUnit.test('blocked after connected',
- function(assert) {
- function checkState(state) {
- signalStrategy.setStateForTesting(state);
- sinon.assert.calledWith(onStateChange, state);
- assert.equal(checker.getState(), state);
- };
-
- checkState(remoting.SignalStrategy.State.CONNECTING);
- checkState(remoting.SignalStrategy.State.HANDSHAKE);
- onStateChange.reset();
-
- // Verify that DnsBlackholeChecker stays in HANDSHAKE state even
- // if the signal strategy has connected.
- return base.SpyPromise.run(function() {
- signalStrategy.setStateForTesting(
- remoting.SignalStrategy.State.CONNECTED);
- }).then(function() {
- sinon.assert.notCalled(onStateChange);
- assert.equal(checker.getState(), remoting.SignalStrategy.State.HANDSHAKE);
-
- // Verify that DnsBlackholeChecker goes to FAILED state after it
- // gets the blocked HTTP response.
- return base.SpyPromise.run(function() {
- fakeXhr.respond(400);
- });
- }).then(function() {
- sinon.assert.calledWith(onStateChange,
- remoting.SignalStrategy.State.FAILED);
- assert.ok(checker.getError().hasTag(remoting.Error.Tag.NOT_AUTHORIZED));
- });
- }
-);
-
-})();
« no previous file with comments | « remoting/webapp/crd/js/dns_blackhole_checker.js ('k') | remoting/webapp/crd/js/error.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698