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 |
index dcf0513ae2d597c1624382e4fc2204db7c838e6d..13916999cb7acfd113f4d9e9a18bbde07d9f12c3 100644 |
--- a/remoting/webapp/browser_test/mock_session_connector.js |
+++ b/remoting/webapp/browser_test/mock_session_connector.js |
@@ -14,39 +14,64 @@ |
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) { |
+ 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() { |
- this.pairingRequested_ = false; |
+ /** @type {string} @private */ |
+ this.hostId_ = ''; |
}; |
remoting.MockSessionConnector.prototype.connectMe2Me = |
function(host, fetchPin, fetchThirdPartyToken, |
clientPairingId, clientPairedSecret) { |
- this.mode_ = remoting.ClientSession.Mode.ME2ME; |
+ this.mode_ = remoting.DesktopConnectedView.Mode.ME2ME; |
this.connect_(); |
}; |
remoting.MockSessionConnector.prototype.retryConnectMe2Me = |
function(host, fetchPin, fetchThirdPartyToken, |
clientPairingId, clientPairedSecret) { |
- this.mode_ = remoting.ClientSession.Mode.ME2ME; |
+ this.mode_ = remoting.DesktopConnectedView.Mode.ME2ME; |
this.connect_(); |
}; |
remoting.MockSessionConnector.prototype.connectMe2App = |
function(host, fetchThirdPartyToken) { |
- this.mode_ = remoting.ClientSession.Mode.ME2APP; |
+ this.mode_ = remoting.DesktopConnectedView.Mode.APP_REMOTING; |
this.connect_(); |
}; |
@@ -56,12 +81,12 @@ remoting.MockSessionConnector.prototype.updatePairingInfo = |
remoting.MockSessionConnector.prototype.connectIT2Me = |
function(accessCode) { |
- this.mode_ = remoting.ClientSession.Mode.ME2ME; |
+ this.mode_ = remoting.DesktopConnectedView.Mode.ME2ME; |
this.connect_(); |
}; |
remoting.MockSessionConnector.prototype.reconnect = function() { |
- base.debug.assert(this.mode_ == remoting.ClientSession.Mode.ME2ME); |
+ base.debug.assert(this.mode_ == remoting.DesktopConnectedView.Mode.ME2ME); |
this.connect_(); |
}; |
@@ -76,14 +101,9 @@ remoting.MockSessionConnector.prototype.getHostId = function() { |
return this.hostId_; |
}; |
-remoting.MockSessionConnector.prototype.requestPairing = function() { |
- this.pairingRequested_ = true; |
-}; |
- |
-remoting.MockSessionConnector.prototype.pairingRequested = function() { |
- return this.pairingRequested_; |
-}; |
- |
+/** |
+ * @suppress {reportUnknownTypes} Required by onStateChange. |
Jamie
2015/02/18 00:51:33
Can you expand on why onStateChange needs this? Al
garykac
2015/02/18 02:06:49
I removed the bind() on onStateChange and switched
|
+ */ |
remoting.MockSessionConnector.prototype.connect_ = function() { |
var signalling = new remoting.MockSignalStrategy(); |
signalling.setStateForTesting(remoting.SignalStrategy.State.CONNECTED); |
@@ -95,10 +115,23 @@ remoting.MockSessionConnector.prototype.connect_ = function() { |
var hostPublicKey = ''; |
var clientPairingId = ''; |
var clientPairedSecret = ''; |
+ |
+ /** |
+ * @param {boolean} offerPairing |
+ * @param {function(string):void} callback |
+ */ |
var fetchPin = function(offerPairing, callback) { |
window.setTimeout(function() { callback('') }, 0); |
}; |
- var fetchThirdPartyToken = function(tokenUrl, scope, callback) { |
+ |
+ /** |
+ * @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); |
}; |
@@ -108,6 +141,9 @@ remoting.MockSessionConnector.prototype.connect_ = function() { |
authenticationMethods, hostId, hostJid, hostPublicKey, |
this.mode_, clientPairingId, clientPairedSecret); |
+ /** |
+ * @param {remoting.ClientSession.StateEvent} event |
+ */ |
var onStateChange = function(event) { |
if (event.current == remoting.ClientSession.State.CONNECTED) { |
this.onConnected_(clientSession); |
@@ -127,8 +163,26 @@ remoting.MockSessionConnector.prototype.connect_ = function() { |
*/ |
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) { |
+ function(clientContainer, onConnected, onError, onExtensionMessage, |
+ onConnectionFailed, requiredCapabilities, defaultRemapKeys) { |
return new remoting.MockSessionConnector( |
- clientContainer, onConnected, onError, onExtensionMessage); |
+ clientContainer, onConnected, onError, onExtensionMessage, |
+ onConnectionFailed, requiredCapabilities, defaultRemapKeys); |
}; |