Commit 133be790 authored by jrw's avatar jrw Committed by Commit bot

Added unit test for HostDaemonFacade.

BUG=471928

Review URL: https://codereview.chromium.org/1060793003

Cr-Commit-Position: refs/heads/master@{#324165}
parent 8caa594c
......@@ -76,6 +76,7 @@
'webapp/crd/js/fallback_signal_strategy_unittest.js',
'webapp/crd/js/gcd_client_unittest.js',
'webapp/crd/js/gcd_client_with_mock_xhr_unittest.js',
'webapp/crd/js/host_daemon_facade_unittest.js',
'webapp/crd/js/host_table_entry_unittest.js',
'webapp/crd/js/identity_unittest.js',
'webapp/crd/js/l10n_unittest.js',
......
This diff is collapsed.
......@@ -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;
};
})();
......@@ -84,8 +84,8 @@ QUnit.Assert.prototype.throws = function(a, opt_b, opt_message) {};
/**
* @typedef {{
* beforeEach: (function(QUnit.Assert=) | undefined),
* afterEach: (function(QUnit.Assert=) | undefined)
* beforeEach: (function(!QUnit.Assert) | undefined),
* afterEach: (function(!QUnit.Assert) | undefined)
* }}
*/
QUnit.ModuleArgs;
......@@ -98,6 +98,6 @@ QUnit.module = function(desc, opt_args) {};
/**
* @param {string} desc
* @param {function(QUnit.Assert)} f
* @param {function(!QUnit.Assert)} f
*/
QUnit.test = function(desc, f) {};
......@@ -73,7 +73,7 @@ sinon.spy = function() {};
* the following can be used to add the sinon.spy functions:
* {(sinon.Spy|function():void)}
*
* @constructor
* @interface
*/
sinon.Spy = function() {};
......@@ -81,13 +81,13 @@ sinon.Spy = function() {};
sinon.Spy.prototype.callCount;
/** @type {boolean} */
sinon.Spy.prototype.called = false;
sinon.Spy.prototype.called;
/** @type {boolean} */
sinon.Spy.prototype.calledOnce = false;
sinon.Spy.prototype.calledOnce;
/** @type {boolean} */
sinon.Spy.prototype.calledTwice = false;
sinon.Spy.prototype.calledTwice;
/** @type {function(...):boolean} */
sinon.Spy.prototype.calledWith = function() {};
......@@ -99,6 +99,9 @@ sinon.Spy.prototype.reset = function() {};
sinon.Spy.prototype.restore = function() {};
/** @type {Array<Array<*>>} */
sinon.Spy.prototype.args;
/**
* @param {Object} obj
* @param {string} method
......@@ -107,7 +110,11 @@ sinon.Spy.prototype.restore = function() {};
*/
sinon.stub = function(obj, method, opt_stubFunction) {};
/** @constructor */
/**
* TODO(jrw): rename to |sinon.Stub| for consistency
* @interface
* @extends {sinon.Spy}
*/
sinon.TestStub = function() {};
/** @type {function(number):{args:Array}} */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment