Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(871)

Side by Side Diff: mojo/edk/js/tests/sample_service_tests.js

Issue 2556353004: Mojo JS bindings: code generator maps interface ptr and request to InterfacePtr and InterfaceReques… (Closed)
Patch Set: . Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "gin/test/expect", 6 "gin/test/expect",
7 "mojo/public/interfaces/bindings/tests/sample_service.mojom", 7 "mojo/public/interfaces/bindings/tests/sample_service.mojom",
8 "mojo/public/interfaces/bindings/tests/sample_import.mojom", 8 "mojo/public/interfaces/bindings/tests/sample_import.mojom",
9 "mojo/public/interfaces/bindings/tests/sample_import2.mojom", 9 "mojo/public/interfaces/bindings/tests/sample_import2.mojom",
10 "mojo/public/js/bindings", 10 "mojo/public/js/bindings",
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 return Promise.resolve(); 66 return Promise.resolve();
67 } 67 }
68 68
69 function testSampleService() { 69 function testSampleService() {
70 function ServiceImpl() { 70 function ServiceImpl() {
71 } 71 }
72 72
73 ServiceImpl.prototype.frobinate = function(foo, baz, port) { 73 ServiceImpl.prototype.frobinate = function(foo, baz, port) {
74 checkFoo(foo); 74 checkFoo(foo);
75 expect(baz).toBe(sample.Service.BazOptions.EXTRA); 75 expect(baz).toBe(sample.Service.BazOptions.EXTRA);
76 bindings.ProxyBindings(port).close(); 76 expect(port.ptr.isBound()).toBeTruthy();
77 return Promise.resolve({result: 1234}); 77 return Promise.resolve({result: 1234});
78 }; 78 };
79 79
80 var foo = makeFoo(); 80 var foo = makeFoo();
81 checkFoo(foo); 81 checkFoo(foo);
82 82
83 var service = new sample.ServicePtr(); 83 var service = new sample.ServicePtr();
84 var request = bindings.makeRequest(service); 84 var request = bindings.makeRequest(service);
85 var serviceBinding = new bindings.Binding( 85 var serviceBinding = new bindings.Binding(
86 sample.Service, new ServiceImpl(), request); 86 sample.Service, new ServiceImpl(), request);
87 87
88 var pipe = core.createMessagePipe(); 88 var port = new sample.PortPtr();
89 bindings.makeRequest(port);
89 var promise = service.frobinate( 90 var promise = service.frobinate(
90 foo, sample.Service.BazOptions.EXTRA, pipe.handle0) 91 foo, sample.Service.BazOptions.EXTRA, port)
91 .then(function(response) { 92 .then(function(response) {
92 expect(response.result).toBe(1234); 93 expect(response.result).toBe(1234);
93 94
94 return Promise.resolve(); 95 return Promise.resolve();
95 }); 96 });
96 97
97 return promise; 98 return promise;
98 } 99 }
99 100
100 function makeFoo() { 101 function makeFoo() {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 expect(foo.extra_bars[i].type).toBe(type); 164 expect(foo.extra_bars[i].type).toBe(type);
164 } 165 }
165 166
166 expect(foo.data.length).toBe(10); 167 expect(foo.data.length).toBe(10);
167 for (var i = 0; i < foo.data.length; ++i) 168 for (var i = 0; i < foo.data.length; ++i)
168 expect(foo.data[i]).toBe(foo.data.length - i); 169 expect(foo.data[i]).toBe(foo.data.length - i);
169 170
170 expect(core.isHandle(foo.source)).toBeTruthy(); 171 expect(core.isHandle(foo.source)).toBeTruthy();
171 } 172 }
172 }); 173 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698