OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 define([ | 5 define([ |
6 "console", | 6 "console", |
7 "mojo/apps/js/test/hexdump", | 7 "mojo/apps/js/test/hexdump", |
8 "gin/test/expect", | 8 "gin/test/expect", |
9 "mojom/sample_service" | 9 "mojom/sample_service" |
10 ], function(console, hexdump, expect, sample) { | 10 ], function(console, hexdump, expect, sample) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 expect(foo.source).toBe(0xFFFF); | 85 expect(foo.source).toBe(0xFFFF); |
86 } | 86 } |
87 | 87 |
88 function ServiceImpl() { | 88 function ServiceImpl() { |
89 } | 89 } |
90 | 90 |
91 ServiceImpl.prototype = Object.create(sample.ServiceStub.prototype); | 91 ServiceImpl.prototype = Object.create(sample.ServiceStub.prototype); |
92 | 92 |
93 ServiceImpl.prototype.frobinate = function(foo, baz, port) { | 93 ServiceImpl.prototype.frobinate = function(foo, baz, port) { |
94 checkFoo(foo); | 94 checkFoo(foo); |
95 expect(baz).toBeTruthy(); | 95 expect(baz).toBe(sample.ServiceStub.BazOptions.BAZ_EXTRA); |
96 expect(port).toBe(10); | 96 expect(port).toBe(10); |
97 global.result = "PASS"; | 97 global.result = "PASS"; |
98 }; | 98 }; |
99 | 99 |
100 function SimpleMessageReceiver() { | 100 function SimpleMessageReceiver() { |
101 } | 101 } |
102 | 102 |
103 SimpleMessageReceiver.prototype.accept = function(message) { | 103 SimpleMessageReceiver.prototype.accept = function(message) { |
104 if (dumpMessageAsHex) | 104 if (dumpMessageAsHex) |
105 console.log(hexdump.dumpArray(message.memory)); | 105 console.log(hexdump.dumpArray(message.memory)); |
106 // Imagine some IPC happened here. | 106 // Imagine some IPC happened here. |
107 var serviceImpl = new ServiceImpl(); | 107 var serviceImpl = new ServiceImpl(); |
108 serviceImpl.accept(message); | 108 serviceImpl.accept(message); |
109 }; | 109 }; |
110 | 110 |
111 var receiver = new SimpleMessageReceiver(); | 111 var receiver = new SimpleMessageReceiver(); |
112 var serviceProxy = new sample.ServiceProxy(receiver); | 112 var serviceProxy = new sample.ServiceProxy(receiver); |
113 | 113 |
114 var foo = makeFoo(); | 114 var foo = makeFoo(); |
115 checkFoo(foo); | 115 checkFoo(foo); |
116 | 116 |
117 var port = 10; | 117 var port = 10; |
118 serviceProxy.frobinate(foo, true, port); | 118 serviceProxy.frobinate(foo, sample.ServiceProxy.BazOptions.BAZ_EXTRA, port); |
119 }); | 119 }); |
OLD | NEW |