goog.testing.messaging.MockMessageChannel
Classgoog.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
}
.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
}
opt_scope
{Object
=}
.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.
.decodePayload(serviceName, payload, objectPayload)
[protected]Inherited from goog.messaging.AbstractChannel
.
Converts the message payload into the format expected by the registered service (either JSON or string).
serviceName
{string
}
payload
{string
|!Object
}
objectPayload
{boolean
}
string
|Object
}
.deliver(serviceName, payload)
[protected]Inherited from goog.messaging.AbstractChannel
.
Delivers a message to the appropriate service. This is meant to be called by subclasses when they receive messages. This method takes into account both explicitly-registered and default services, as well as making sure that JSON payloads are decoded when necessary. If the subclass is capable of passing objects as payloads, those objects can be passed in to this method directly. Otherwise, the (potentially JSON-encoded) strings should be passed in.
serviceName
{string
}
payload
{string
|!Object
}
.dispose()
Sets a flag indicating that this is disposed.
.disposeInternal()
[protected]Inherited from goog.messaging.AbstractChannel
.
Deletes or nulls out any references to COM objects, DOM nodes, or other disposable objects. Classes that extend {@code goog.Disposable} should override this method. Not reentrant. To avoid calling it twice, it must only be called from the subclass' {@code disposeInternal} method. Everywhere else the public {@code dispose} method must be used. For example:
mypackage.MyClass = function() { goog.base(this); // Constructor logic specific to MyClass. ... }; goog.inherits(mypackage.MyClass, goog.Disposable); mypackage.MyClass.prototype.disposeInternal = function() { goog.base(this, 'disposeInternal'); // Dispose logic specific to MyClass. ... };
.disposed
{boolean
}Whether the channel has been disposed.
.getDisposed
[deprecated]Deprecated. Use {@link #isDisposed} instead.
Inherited from goog.Disposable
.
boolean
}
.getService(serviceName, payload)
[protected]Inherited from goog.messaging.AbstractChannel
.
Find the service object for a given service name. If there's no service explicitly registered, but there is a default service, a service object is constructed for it.
serviceName
{string
}
payload
{string
|!Object
}
callback
: function
((string
|!Object
)), objectPayload
: boolean
}}
.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
.
boolean
}
.logger
[protected] {goog.debug.Logger
}Inherited from goog.messaging.AbstractChannel
.
Logger for this class.
.receive(serviceName, payload)
Mocks the receipt of a message. Passes the payload the appropriate service.
serviceName
{string
}
payload
{string
|!Object
}
.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
}
.registerService()
Inherited from goog.messaging.AbstractChannel
.
.send(serviceName, payload)
A mock send function. Actually an instance of {@link goog.testing.FunctionMock}.
serviceName
{string
}
payload
{string
|!Object
}