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

Unified Diff: remoting/webapp/crd/js/xmpp_connection_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/xmpp_connection.js ('k') | remoting/webapp/crd/js/xmpp_login_handler.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/crd/js/xmpp_connection_unittest.js
diff --git a/remoting/webapp/crd/js/xmpp_connection_unittest.js b/remoting/webapp/crd/js/xmpp_connection_unittest.js
deleted file mode 100644
index a96ef9bde1c5638ed0362f1e3d50ca31ef36400e..0000000000000000000000000000000000000000
--- a/remoting/webapp/crd/js/xmpp_connection_unittest.js
+++ /dev/null
@@ -1,125 +0,0 @@
-// Copyright 2014 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.
-
-(function() {
-
-'use strict';
-
-var testUsername = 'testUsername@gmail.com';
-var testToken = 'testToken';
-var socketId = 3;
-
-var onStanzaStr = null;
-
-/** @type {remoting.XmppConnection} */
-var connection = null;
-
-/** @type {remoting.TcpSocket} */
-var socket = null;
-
-var stateChangeHandler = function(/** remoting.SignalStrategy.State */ state) {}
-
-function onStateChange(/** remoting.SignalStrategy.State */ state) {
- stateChangeHandler(state)
-};
-
-/**
- * @param {QUnit.Assert} assert
- * @param {remoting.SignalStrategy.State} expectedState
- * @returns {Promise}
- */
-function expectNextState(assert, expectedState) {
- return new Promise(function(resolve, reject) {
- stateChangeHandler = function(/** remoting.SignalStrategy.State */ state) {
- assert.equal(state, expectedState);
- assert.equal(connection.getState(), expectedState);
- resolve(0);
- }
- });
-}
-
-QUnit.module('XmppConnection', {
- beforeEach: function() {
- onStanzaStr = sinon.spy();
- /** @param {Element} stanza */
- function onStanza(stanza) {
- onStanzaStr(new XMLSerializer().serializeToString(stanza));
- }
-
- socket = /** @type{remoting.TcpSocket} */
- (sinon.createStubInstance(remoting.TcpSocket));
-
- connection = new remoting.XmppConnection();
- connection.setSocketForTests(socket);
- connection.setStateChangedCallback(onStateChange);
- connection.setIncomingStanzaCallback(onStanza);
- }
-});
-
-QUnit.test('should go to FAILED state when failed to connect',
- function(assert) {
- var done = assert.async();
- $testStub(socket.connect).withArgs("xmpp.example.com", 123)
- .returns(new Promise(function(resolve, reject) { reject(-1); }));
-
- var deferredSend = new base.Deferred();
- $testStub(socket.send).onFirstCall().returns(deferredSend.promise());
-
- expectNextState(assert, remoting.SignalStrategy.State.CONNECTING)
- .then(onConnecting);
- connection.connect('xmpp.example.com:123', 'testUsername@gmail.com',
- 'testToken');
-
- function onConnecting() {
- expectNextState(assert, remoting.SignalStrategy.State.FAILED)
- .then(onFailed);
- }
-
- function onFailed() {
- sinon.assert.calledWith(socket.dispose);
- assert.ok(connection.getError().hasTag(remoting.Error.Tag.NETWORK_FAILURE));
- done();
- }
-});
-
-QUnit.test('should use XmppLoginHandler for handshake', function(assert) {
-
- $testStub(socket.connect).withArgs("xmpp.example.com", 123)
- .returns(new Promise(function(resolve, reject) { resolve(0) }));
-
- var deferredSend = new base.Deferred();
- $testStub(socket.send).onFirstCall().returns(deferredSend.promise());
-
- var parser = new remoting.XmppStreamParser();
- var parserMock = sinon.mock(parser);
- var setCallbacksCalled = parserMock.expects('setCallbacks').once();
- var State = remoting.SignalStrategy.State;
-
- var promise = expectNextState(assert, State.CONNECTING).then(function() {
- return expectNextState(assert, State.HANDSHAKE);
- }).then(function() {
- var handshakeDoneCallback =
- connection.loginHandler_.getHandshakeDoneCallbackForTesting();
- var onConnected = expectNextState(assert, State.CONNECTED);
- handshakeDoneCallback('test@example.com/123123', parser);
- return onConnected;
- }).then(function() {
- setCallbacksCalled.verify();
-
- // Simulate read() callback with |data|. It should be passed to
- // the parser.
- var data = base.encodeUtf8('<iq id="1">hello</iq>');
- sinon.assert.calledWith(socket.startReceiving);
- var appendDataCalled =
- parserMock.expects('appendData').once().withArgs(data);
- $testStub(socket.startReceiving).getCall(0).args[0](data);
- appendDataCalled.verify();
- });
-
- connection.connect(
- 'xmpp.example.com:123', 'testUsername@gmail.com', 'testToken');
- return promise;
-});
-
-})();
« no previous file with comments | « remoting/webapp/crd/js/xmpp_connection.js ('k') | remoting/webapp/crd/js/xmpp_login_handler.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698