OLD | NEW |
1 'use strict'; | 1 'use strict'; |
2 | 2 |
3 // Sometimes we need to test that using either the name, alias, or UUID | 3 // Sometimes we need to test that using either the name, alias, or UUID |
4 // produces the same result. The following objects help us do that. | 4 // produces the same result. The following objects help us do that. |
5 var generic_access = { | 5 var generic_access = { |
6 alias: 0x1800, | 6 alias: 0x1800, |
7 name: 'generic_access', | 7 name: 'generic_access', |
8 uuid: '00001800-0000-1000-8000-00805f9b34fb' | 8 uuid: '00001800-0000-1000-8000-00805f9b34fb' |
9 }; | 9 }; |
10 var device_name = { | 10 var device_name = { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 function assert_promise_rejects_with_message(promise, expected, description) { | 78 function assert_promise_rejects_with_message(promise, expected, description) { |
79 return promise.then(() => { | 79 return promise.then(() => { |
80 assert_unreached('Promise should have rejected: ' + description); | 80 assert_unreached('Promise should have rejected: ' + description); |
81 }, error => { | 81 }, error => { |
82 assert_equals(error.name, expected.name, 'Unexpected Error Name:'); | 82 assert_equals(error.name, expected.name, 'Unexpected Error Name:'); |
83 if (expected.message) { | 83 if (expected.message) { |
84 assert_equals(error.message, expected.message, 'Unexpected Error Message:'
); | 84 assert_equals(error.message, expected.message, 'Unexpected Error Message:'
); |
85 } | 85 } |
86 }); | 86 }); |
87 } | 87 } |
| 88 |
| 89 // Parses add-device(name)=id lines in |
| 90 // testRunner.getBluetoothManualChooserEvents() output, and exposes the name->id |
| 91 // mapping. |
| 92 class AddDeviceEventSet { |
| 93 constructor() { |
| 94 this._idsByName = new Map(); |
| 95 this._addDeviceRegex = /^add-device\(([^)]+)\)=(.+)$/; |
| 96 } |
| 97 assert_add_device_event(event, description) { |
| 98 let match = this._addDeviceRegex.exec(event); |
| 99 assert_true(!!match, event + "isn't an add-device event: " + description); |
| 100 this._idsByName.set(match[1], match[2]); |
| 101 } |
| 102 has(name) { |
| 103 return this._idsByName.has(name); |
| 104 } |
| 105 get(name) { |
| 106 return this._idsByName.get(name); |
| 107 } |
| 108 } |
OLD | NEW |