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

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

Issue 1086563005: [Chromoting] Use MockConnection for bump scrolling browser test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@IncludeBTinWebapp
Patch Set: Rebase Created 5 years, 8 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/bump_scroll_browser_test.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/crd/js/mock_client_plugin.js
diff --git a/remoting/webapp/crd/js/mock_client_plugin.js b/remoting/webapp/crd/js/mock_client_plugin.js
index 1f2ba5c81736dd37f9c0b4adcd0dc9299f933454..68be5e161fbda229f763b2d36d157e836e8fde5b 100644
--- a/remoting/webapp/crd/js/mock_client_plugin.js
+++ b/remoting/webapp/crd/js/mock_client_plugin.js
@@ -29,6 +29,10 @@ remoting.MockClientPlugin = function() {
new remoting.ClientPlugin.HostDesktopImpl(this, base.doNothing);
/** @private */
this.extensions_ = new remoting.ProtocolExtensionManager(base.doNothing);
+
+ /** @private {remoting.CredentialsProvider} */
+ this.credentials_ = null;
+
/** @private {remoting.ClientPlugin.ConnectionEventHandler} */
this.connectionEventHandler_ = null;
@@ -73,6 +77,7 @@ remoting.MockClientPlugin.prototype.initialize = function(onDone) {
remoting.MockClientPlugin.prototype.connect =
function(host, localJid, credentialsProvider) {
+ this.credentials_ = credentialsProvider;
this.onConnectDeferred_.resolve();
};
@@ -163,6 +168,50 @@ remoting.MockClientPlugin.prototype.mock$setConnectionStatus = function(
};
/**
+ * @param {remoting.MockClientPlugin.AuthMethod} authMethod
+ * @return {Promise}
+ */
+remoting.MockClientPlugin.prototype.mock$authenticate = function(authMethod) {
+ var AuthMethod = remoting.MockClientPlugin.AuthMethod;
+ var deferred = new base.Deferred();
+
+ var that = this;
+ switch(authMethod) {
+ case AuthMethod.PIN:
+ case AuthMethod.ACCESS_CODE:
+ this.credentials_.getPIN(true).then(function() {
+ deferred.resolve();
+ });
+ break;
+ case AuthMethod.THIRD_PARTY:
+ this.credentials_.getThirdPartyToken(
+ 'fake_token_url', 'fake_host_publicKey', 'fake_scope'
+ ).then(function() {
+ deferred.resolve();
+ });
+ break;
+ case AuthMethod.PAIRING:
+ deferred.resolve();
+ }
+ return deferred.promise();
+};
+
+/**
+ * @param {remoting.MockClientPlugin.AuthMethod} authMethod
+ */
+remoting.MockClientPlugin.prototype.mock$useDefaultBehavior =
+ function(authMethod) {
+ var that = this;
+ var State = remoting.ClientSession.State;
+ this.mock$onConnect().then(function() {
+ that.mock$setConnectionStatus(State.CONNECTING);
+ return that.mock$authenticate(authMethod);
+ }).then(function() {
+ that.mock$setConnectionStatus(State.CONNECTED);
+ });
+};
+
+/**
* @constructor
* @implements {remoting.ClientPluginFactory}
*/
@@ -235,4 +284,12 @@ remoting.MockConnection.prototype.restore = function() {
this.createSignalStrategyStub_.restore();
};
-})();
+})();
+
+/** @enum {string} */
+remoting.MockClientPlugin.AuthMethod = {
+ ACCESS_CODE: 'accessCode',
+ PIN: 'pin',
+ THIRD_PARTY: 'thirdParty',
+ PAIRING: 'pairing'
+};
« no previous file with comments | « remoting/webapp/browser_test/bump_scroll_browser_test.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698