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

Unified Diff: remoting/webapp/browser_test/mock_session_connector.js

Issue 984203003: Move mocks and unittest JS files to sit alongside production code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 9 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/browser_test/mock_oauth2_api.js ('k') | remoting/webapp/crd/html/template_unittest.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/browser_test/mock_session_connector.js
diff --git a/remoting/webapp/browser_test/mock_session_connector.js b/remoting/webapp/browser_test/mock_session_connector.js
deleted file mode 100644
index 12c5a80e1b5c3afea3540948763d4a9fdbbe7782..0000000000000000000000000000000000000000
--- a/remoting/webapp/browser_test/mock_session_connector.js
+++ /dev/null
@@ -1,183 +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.
-
-/**
- * @fileoverview
- * Mock implementation of SessionConnector for testing.
- * @suppress {checkTypes}
- */
-
-'use strict';
-
-/** @suppress {duplicate} */
-var remoting = remoting || {};
-
-/**
- * @param {HTMLElement} clientContainer Container element for the client view.
- * @param {function(remoting.ClientSession):void} onConnected Callback on
- * success.
- * @param {function(!remoting.Error):void} onError Callback on error.
- * @param {function(string, string):boolean} onExtensionMessage The handler for
- * protocol extension messages. Returns true if a message is recognized;
- * false otherwise.
- * @param {function(!remoting.Error):void} onConnectionFailed Callback for when
- * the connection fails.
- * @param {Array<string>} requiredCapabilities Connector capabilities
- * required by this application.
- * @param {string} defaultRemapKeys The default set of key mappings for the
- * client session to use.
- * @constructor
- * @implements {remoting.SessionConnector}
- */
-remoting.MockSessionConnector = function(clientContainer, onConnected, onError,
- onExtensionMessage,
- onConnectionFailed,
- requiredCapabilities,
- defaultRemapKeys) {
- this.clientContainer_ = clientContainer;
- /** @type {function(remoting.ClientSession):void} */
- this.onConnected_ = onConnected;
- this.onError = onError;
- this.onExtensionMessage_ = onExtensionMessage;
- this.onConnectionFailed_ = onConnectionFailed;
- this.requiredCapabilities_ = requiredCapabilities;
- this.defaultRemapKeys_ = defaultRemapKeys;
-
- /** @type {remoting.DesktopConnectedView.Mode} */
- this.mode_ = remoting.DesktopConnectedView.Mode.ME2ME;
-
- this.reset();
-};
-
-remoting.MockSessionConnector.prototype.reset = function() {
- /** @type {string} @private */
- this.hostId_ = '';
-};
-
-remoting.MockSessionConnector.prototype.connectMe2Me =
- function(host, fetchPin, fetchThirdPartyToken,
- clientPairingId, clientPairedSecret) {
- this.mode_ = remoting.DesktopConnectedView.Mode.ME2ME;
- this.connect_();
-};
-
-remoting.MockSessionConnector.prototype.retryConnectMe2Me =
- function(host, fetchPin, fetchThirdPartyToken,
- clientPairingId, clientPairedSecret) {
- this.mode_ = remoting.DesktopConnectedView.Mode.ME2ME;
- this.connect_();
-};
-
-remoting.MockSessionConnector.prototype.connectMe2App =
- function(host, fetchThirdPartyToken) {
- this.mode_ = remoting.DesktopConnectedView.Mode.APP_REMOTING;
- this.connect_();
-};
-
-remoting.MockSessionConnector.prototype.updatePairingInfo =
- function(clientId, sharedSecret) {
-};
-
-remoting.MockSessionConnector.prototype.connectIT2Me =
- function(accessCode) {
- this.mode_ = remoting.DesktopConnectedView.Mode.ME2ME;
- this.connect_();
-};
-
-remoting.MockSessionConnector.prototype.reconnect = function() {
- base.debug.assert(this.mode_ == remoting.DesktopConnectedView.Mode.ME2ME);
- this.connect_();
-};
-
-remoting.MockSessionConnector.prototype.cancel = function() {
-};
-
-remoting.MockSessionConnector.prototype.getConnectionMode = function() {
- return this.mode_;
-};
-
-remoting.MockSessionConnector.prototype.getHostId = function() {
- return this.hostId_;
-};
-
-remoting.MockSessionConnector.prototype.connect_ = function() {
- var signalling = new remoting.MockSignalStrategy();
- signalling.setStateForTesting(remoting.SignalStrategy.State.CONNECTED);
- var hostName = 'Mock host';
- var accessCode = '';
- var authenticationMethods = '';
- var hostId = '';
- var hostJid = '';
- var hostPublicKey = '';
- var clientPairingId = '';
- var clientPairedSecret = '';
-
- /**
- * @param {boolean} offerPairing
- * @param {function(string):void} callback
- */
- var fetchPin = function(offerPairing, callback) {
- window.setTimeout(function() { callback('') }, 0);
- };
-
- /**
- * @param {string} tokenUrl
- * @param {string} hostPublicKey
- * @param {string} scope
- * @param {function(string, string):void} callback
- */
- var fetchThirdPartyToken = function(tokenUrl, hostPublicKey, scope,
- callback) {
- window.setTimeout(function() { callback('', '') }, 0);
- };
-
- var clientSession = new remoting.ClientSession(
- signalling, this.clientContainer_, hostName,
- accessCode, fetchPin, fetchThirdPartyToken,
- authenticationMethods, hostId, hostJid, hostPublicKey,
- this.mode_, clientPairingId, clientPairedSecret);
-
- var that = this;
- /** @param {remoting.ClientSession.StateEvent} event */
- var onStateChange = function(event) {
- if (event.current == remoting.ClientSession.State.CONNECTED) {
- that.onConnected_(clientSession);
- }
- };
-
- clientSession.addEventListener(
- remoting.ClientSession.Events.stateChanged,
- onStateChange);
-};
-
-
-/**
- * @constructor
- * @extends {remoting.SessionConnectorFactory}
- */
-remoting.MockSessionConnectorFactory = function() {};
-
-/**
- * @param {HTMLElement} clientContainer Container element for the client view.
- * @param {function(remoting.ClientSession):void} onConnected Callback on
- * success.
- * @param {function(!remoting.Error):void} onError Callback on error.
- * @param {function(string, string):boolean} onExtensionMessage The handler for
- * protocol extension messages. Returns true if a message is recognized;
- * false otherwise.
- * @param {function(!remoting.Error):void} onConnectionFailed Callback for when
- * the connection fails.
- * @param {Array<string>} requiredCapabilities Connector capabilities
- * required by this application.
- * @param {string} defaultRemapKeys The default set of key mappings to use
- * in the client session.
- * @return {remoting.MockSessionConnector}
- */
-remoting.MockSessionConnectorFactory.prototype.createConnector =
- function(clientContainer, onConnected, onError, onExtensionMessage,
- onConnectionFailed, requiredCapabilities, defaultRemapKeys) {
- return new remoting.MockSessionConnector(
- clientContainer, onConnected, onError, onExtensionMessage,
- onConnectionFailed, requiredCapabilities, defaultRemapKeys);
-};
« no previous file with comments | « remoting/webapp/browser_test/mock_oauth2_api.js ('k') | remoting/webapp/crd/html/template_unittest.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698