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

Unified Diff: remoting/webapp/js_proto/chrome_mocks.js

Issue 1013633003: remoting.Identity unit-tests and fixes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix jscompile errors. 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/crd/js/identity_unittest.js ('k') | remoting/webapp/js_proto/sinon_proto.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/js_proto/chrome_mocks.js
diff --git a/remoting/webapp/js_proto/chrome_mocks.js b/remoting/webapp/js_proto/chrome_mocks.js
index a1e449090dc9215314166dffe10c3374125380aa..3b404b64ccf506d8c84eff075b835712fd9775f9 100644
--- a/remoting/webapp/js_proto/chrome_mocks.js
+++ b/remoting/webapp/js_proto/chrome_mocks.js
@@ -104,7 +104,11 @@ chromeMocks.runtime.sendMessage = function(extensionId, message,
chromeMocks.runtime.id = 'extensionId';
/** @type {Object} */
-chromeMocks.storage = {};
+chromeMocks.runtime.lastError = {
+ /** @type {string|undefined} */
+ message: undefined
+};
+
// Sample implementation of chrome.StorageArea according to
// https://developer.chrome.com/apps/storage#type-StorageArea
@@ -170,9 +174,41 @@ chromeMocks.StorageArea.prototype.clear = function() {
this.storage_ = null;
};
+/** @type {Object} */
+chromeMocks.storage = {};
+
/** @type {chromeMocks.StorageArea} */
chromeMocks.storage.local = new chromeMocks.StorageArea();
+
+/** @constructor */
+chromeMocks.Identity = function() {
+ /** @private {string|undefined} */
+ this.token_ = undefined;
+};
+
+/**
+ * @param {Object} options
+ * @param {function(string=):void} callback
+ */
+chromeMocks.Identity.prototype.getAuthToken = function(options, callback) {
+ // Don't use setTimeout because sinon mocks it.
+ window.requestAnimationFrame(callback.bind(null, this.token_));
+};
+
+/** @param {string} token */
+chromeMocks.Identity.prototype.mock$setToken = function(token) {
+ this.token_ = token;
+};
+
+chromeMocks.Identity.prototype.mock$clearToken = function() {
+ this.token_ = undefined;
+};
+
+/** @type {chromeMocks.Identity} */
+chromeMocks.identity = new chromeMocks.Identity();
+
+
var originals_ = null;
/**
« no previous file with comments | « remoting/webapp/crd/js/identity_unittest.js ('k') | remoting/webapp/js_proto/sinon_proto.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698