OLD | NEW |
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 23 matching lines...) Expand all Loading... |
34 | 34 |
35 function usbMocks(mojo) { | 35 function usbMocks(mojo) { |
36 return define('USB Mocks', [ | 36 return define('USB Mocks', [ |
37 'mojo/public/js/bindings', | 37 'mojo/public/js/bindings', |
38 'mojo/public/js/connection', | 38 'mojo/public/js/connection', |
39 'device/usb/public/interfaces/chooser_service.mojom', | 39 'device/usb/public/interfaces/chooser_service.mojom', |
40 'device/usb/public/interfaces/device_manager.mojom', | 40 'device/usb/public/interfaces/device_manager.mojom', |
41 'device/usb/public/interfaces/device.mojom', | 41 'device/usb/public/interfaces/device.mojom', |
42 ], (bindings, connection, chooserService, deviceManager, device) => { | 42 ], (bindings, connection, chooserService, deviceManager, device) => { |
43 function assertDeviceInfoEquals(device, info) { | 43 function assertDeviceInfoEquals(device, info) { |
44 assert_equals(device.guid, info.guid); | |
45 assert_equals(device.usbVersionMajor, info.usb_version_major); | 44 assert_equals(device.usbVersionMajor, info.usb_version_major); |
46 assert_equals(device.usbVersionMinor, info.usb_version_minor); | 45 assert_equals(device.usbVersionMinor, info.usb_version_minor); |
47 assert_equals(device.usbVersionSubminor, info.usb_version_subminor); | 46 assert_equals(device.usbVersionSubminor, info.usb_version_subminor); |
48 assert_equals(device.deviceClass, info.class_code); | 47 assert_equals(device.deviceClass, info.class_code); |
49 assert_equals(device.deviceSubclass, info.subclass_code); | 48 assert_equals(device.deviceSubclass, info.subclass_code); |
50 assert_equals(device.deviceProtocol, info.protocol_code); | 49 assert_equals(device.deviceProtocol, info.protocol_code); |
51 assert_equals(device.vendorId, info.vendor_id); | 50 assert_equals(device.vendorId, info.vendor_id); |
52 assert_equals(device.productId, info.product_id); | 51 assert_equals(device.productId, info.product_id); |
53 assert_equals(device.deviceVersionMajor, info.device_version_major); | 52 assert_equals(device.deviceVersionMajor, info.device_version_major); |
54 assert_equals(device.deviceVersionMinor, info.device_version_minor); | 53 assert_equals(device.deviceVersionMinor, info.device_version_minor); |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 bindToPipe(pipe) { | 331 bindToPipe(pipe) { |
333 this.stub_ = connection.bindHandleToStub( | 332 this.stub_ = connection.bindHandleToStub( |
334 pipe, deviceManager.DeviceManager); | 333 pipe, deviceManager.DeviceManager); |
335 bindings.StubBindings(this.stub_).delegate = this; | 334 bindings.StubBindings(this.stub_).delegate = this; |
336 } | 335 } |
337 | 336 |
338 reset() { | 337 reset() { |
339 this.mockDevices_.forEach(device => { | 338 this.mockDevices_.forEach(device => { |
340 for (var stub of device.stubs) | 339 for (var stub of device.stubs) |
341 bindings.StubBindings(stub).close(); | 340 bindings.StubBindings(stub).close(); |
| 341 this.client_.onDeviceRemoved(device.info); |
342 }); | 342 }); |
343 this.mockDevices_.clear(); | 343 this.mockDevices_.clear(); |
344 } | 344 } |
345 | 345 |
346 addMockDevice(info) { | 346 addMockDevice(info) { |
347 let device = { | 347 let device = { |
348 info: info, | 348 info: info, |
349 stubs: [] | 349 stubs: [] |
350 }; | 350 }; |
351 this.mockDevices_.set(info.guid, device); | 351 this.mockDevices_.set(info.guid, device); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 } | 442 } |
443 | 443 |
444 function usb_test(func, name, properties) { | 444 function usb_test(func, name, properties) { |
445 mojo_test(mojo => usbMocks(mojo).then(usb => { | 445 mojo_test(mojo => usbMocks(mojo).then(usb => { |
446 let result = Promise.resolve(func(usb)); | 446 let result = Promise.resolve(func(usb)); |
447 let cleanUp = () => usb.mockDeviceManager.reset(); | 447 let cleanUp = () => usb.mockDeviceManager.reset(); |
448 result.then(cleanUp, cleanUp); | 448 result.then(cleanUp, cleanUp); |
449 return result; | 449 return result; |
450 }), name, properties); | 450 }), name, properties); |
451 } | 451 } |
OLD | NEW |