The goog.testing.messaging.MockMessageChannel Class

goog.testing.messaging.MockMessageChannel
> goog.messaging.AbstractChannel
> goog.Disposable

goog.testing.messaging.MockMessageChannel(mockControl)

Class for unit-testing code that communicates over a MessageChannel.

mockControl {goog.testing.MockControl}
The mock control used to create the method mock for #send.

.addOnDisposeCallback(callback, opt_scope)

Inherited from goog.Disposable .

Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.

callback {!Function}
The callback function.
opt_scope {Object=}
An optional scope to call the callback in.

.connect()

Inherited from goog.messaging.AbstractChannel .

Immediately calls opt_connectCb if given, and is otherwise a no-op. If subclasses have configuration that needs to happen before the channel is connected, they should override this and {@link #isConnected}.

.creationStack {string}

Inherited from goog.Disposable .

If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.

.dispose()

Sets a flag indicating that this is disposed.

.disposed {boolean}

Whether the channel has been disposed.

.isConnected()

Inherited from goog.messaging.AbstractChannel .

Always returns true. If subclasses have configuration that needs to happen before the channel is connected, they should override this and {@link #connect}.

.isDisposed()

Inherited from goog.Disposable .

returns {boolean}
Whether the object has been disposed of.

.receive(serviceName, payload)

Mocks the receipt of a message. Passes the payload the appropriate service.

serviceName {string}
The service to run.
payload {string|!Object}
The argument to pass to the service.

.registerDefaultService()

Inherited from goog.messaging.AbstractChannel .

.registerDisposable(disposable)

Inherited from goog.Disposable .

Associates a disposable object with this object so that they will be disposed together.

disposable {goog.disposable.IDisposable}
that will be disposed when this object is disposed.

.registerService()

Inherited from goog.messaging.AbstractChannel .

.send(serviceName, payload)

A mock send function. Actually an instance of {@link goog.testing.FunctionMock}.

serviceName {string}
The name of the remote service to run.
payload {string|!Object}
The payload to send to the remote page.