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

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

Issue 1060793003: Added unit test for HostDaemonFacade. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mock-xhr
Patch Set: license 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/crd/js/host_daemon_facade_unittest.js ('k') | remoting/webapp/js_proto/qunit_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 e64421db527c5d8ef483d5f633452e66fb928613..d18e8045a7341194287e1537a17df150dd3a2b01 100644
--- a/remoting/webapp/js_proto/chrome_mocks.js
+++ b/remoting/webapp/js_proto/chrome_mocks.js
@@ -62,7 +62,10 @@ chromeMocks.runtime = {};
/** @constructor */
chromeMocks.runtime.Port = function() {
+ /** @const */
this.onMessage = new chromeMocks.Event();
+
+ /** @const */
this.onDisconnect = new chromeMocks.Event();
/** @type {string} */
@@ -100,6 +103,24 @@ chromeMocks.runtime.sendMessage = function(extensionId, message,
});
};
+/**
+ * Always returns the same mock port for given application name.
+ * @param {string} application
+ * @return {chromeMocks.runtime.Port}
+ */
+chromeMocks.runtime.connectNative = function(application) {
+ var port = nativePorts[application];
+ if (port === undefined) {
+ port = new chromeMocks.runtime.Port();
+ port.name = application;
+ nativePorts[application] = port;
+ }
+ return port;
+};
+
+/** @const {Object<string,!chromeMocks.runtime.Port>} */
+var nativePorts = null;
+
/** @type {string} */
chromeMocks.runtime.id = 'extensionId';
@@ -225,6 +246,7 @@ chromeMocks.activate = function(components) {
throw new Error('chromeMocks.activate() can only be called once.');
}
originals_ = {};
+ nativePorts = {};
components.forEach(function(component) {
if (!chromeMocks[component]) {
throw new Error('No mocks defined for chrome.' + component);
@@ -242,6 +264,7 @@ chromeMocks.restore = function() {
chrome[components] = originals_[components];
}
originals_ = null;
+ nativePorts = null;
};
})();
« no previous file with comments | « remoting/webapp/crd/js/host_daemon_facade_unittest.js ('k') | remoting/webapp/js_proto/qunit_proto.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698