aboutsummaryrefslogtreecommitdiff
path: root/contexts/data/lib/closure-library/closure/goog/messaging/portcaller_test.html
blob: 7863569a2f5ce87faac775478e897cc6f2125148 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html>
<!--
Copyright 2011 The Closure Library Authors. All Rights Reserved.

Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<!--
-->
<head>
<title>
  Closure Unit Tests - goog.messaging.PortCaller
</title>
<script src="../base.js"></script>
<script>
goog.require('goog.events.EventTarget');
goog.require('goog.messaging.PortCaller');
goog.require('goog.messaging.PortChannel');
goog.require('goog.messaging.PortNetwork');
goog.require('goog.testing.MockControl');
goog.require('goog.testing.jsunit');
goog.require('goog.testing.messaging.MockMessageChannel');
</script>
</head>
<body>
<script>

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) {
  goog.base(this);
  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');
}

</script>
</body>
</html>