12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- goog.provide('goog.messaging.PortCallerTest');
- goog.setTestOnly('goog.messaging.PortCallerTest');
- goog.require('goog.events.EventTarget');
- goog.require('goog.messaging.PortCaller');
- goog.require('goog.messaging.PortNetwork');
- goog.require('goog.testing.MockControl');
- goog.require('goog.testing.jsunit');
- goog.require('goog.testing.messaging.MockMessageChannel');
- var mockControl;
- var mockChannel;
- var caller;
- function setUp() {
- mockControl = new goog.testing.MockControl();
- mockChannel = new goog.testing.messaging.MockMessageChannel(mockControl);
- caller = new goog.messaging.PortCaller(mockChannel);
- }
- function tearDown() {
- goog.dispose(caller);
- mockControl.$verifyAll();
- }
- function MockMessagePort(index, port) {
- MockMessagePort.base(this, 'constructor');
- this.index = index;
- this.port = port;
- this.started = false;
- }
- goog.inherits(MockMessagePort, goog.events.EventTarget);
- MockMessagePort.prototype.start = function() {
- this.started = true;
- };
- function testGetPort() {
- mockChannel.send(
- goog.messaging.PortNetwork.REQUEST_CONNECTION_SERVICE, 'foo');
- mockControl.$replayAll();
- caller.dial('foo');
- }
|