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

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: 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
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..ffc7f6eab2c7bdbdfee21417128db29925ca4795 100644
--- a/remoting/webapp/js_proto/chrome_mocks.js
+++ b/remoting/webapp/js_proto/chrome_mocks.js
@@ -103,8 +103,11 @@ chromeMocks.runtime.sendMessage = function(extensionId, message,
/** @type {string} */
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 +173,37 @@ 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;
+};
+
+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;
/**
« remoting/webapp/crd/js/identity.js ('K') | « remoting/webapp/crd/js/identity_unittest.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698