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

Side by Side Diff: third_party/WebKit/LayoutTests/usb/resources/usb-helpers.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 'use strict'; 1 'use strict';
2 2
3 function assertRejectsWithError(promise, name, message) { 3 function assertRejectsWithError(promise, name, message) {
4 return promise.then(() => { 4 return promise.then(() => {
5 assert_unreached('expected promise to reject with ' + name); 5 assert_unreached('expected promise to reject with ' + name);
6 }, error => { 6 }, error => {
7 assert_equals(error.name, name); 7 assert_equals(error.name, name);
8 if (message !== undefined) 8 if (message !== undefined)
9 assert_equals(error.message, message); 9 assert_equals(error.message, message);
10 }); 10 });
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 } 367 }
368 368
369 getDevices(options) { 369 getDevices(options) {
370 let devices = []; 370 let devices = [];
371 this.mockDevices_.forEach(device => { 371 this.mockDevices_.forEach(device => {
372 devices.push(device.info); 372 devices.push(device.info);
373 }); 373 });
374 return Promise.resolve({ results: devices }); 374 return Promise.resolve({ results: devices });
375 } 375 }
376 376
377 getDevice(guid, stub) { 377 getDevice(guid, request) {
378 let device = this.mockDevices_.get(guid); 378 let deviceData = this.mockDevices_.get(guid);
379 if (device === undefined) { 379 if (deviceData === undefined) {
380 bindings.StubBindings(stub).close(); 380 request.close();
381 } else { 381 } else {
382 var mock = new MockDevice(device.info); 382 var stub = connection.bindHandleToStub(request.handle, device.Device);
383 var mock = new MockDevice(deviceData.info);
383 bindings.StubBindings(stub).delegate = mock; 384 bindings.StubBindings(stub).delegate = mock;
384 bindings.StubBindings(stub).connectionErrorHandler = () => { 385 bindings.StubBindings(stub).connectionErrorHandler = () => {
385 if (this.deviceCloseHandler_) 386 if (this.deviceCloseHandler_)
386 this.deviceCloseHandler_(device.info); 387 this.deviceCloseHandler_(deviceData.info);
387 }; 388 };
388 device.stubs.push(stub); 389 deviceData.stubs.push(stub);
389 } 390 }
390 } 391 }
391 392
392 setClient(client) { 393 setClient(client) {
393 this.client_ = client; 394 this.client_ = client;
394 } 395 }
395 } 396 }
396 397
397 class MockChooserService { 398 class MockChooserService {
398 constructor() { 399 constructor() {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 } 443 }
443 444
444 function usb_test(func, name, properties) { 445 function usb_test(func, name, properties) {
445 mojo_test(mojo => usbMocks(mojo).then(usb => { 446 mojo_test(mojo => usbMocks(mojo).then(usb => {
446 let result = Promise.resolve(func(usb)); 447 let result = Promise.resolve(func(usb));
447 let cleanUp = () => usb.mockDeviceManager.reset(); 448 let cleanUp = () => usb.mockDeviceManager.reset();
448 result.then(cleanUp, cleanUp); 449 result.then(cleanUp, cleanUp);
449 return result; 450 return result;
450 }), name, properties); 451 }), name, properties);
451 } 452 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698