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

Side by Side Diff: third_party/WebKit/LayoutTests/resources/bluetooth/web-bluetooth-test.js

Issue 2874873003: bluetooth: Implement simulateGATTConnectionResponse() (Closed)
Patch Set: Merge branch 'bluetooth-generate-with-headers' into bluetooth-simulate-gatt-discovery-complete Created 3 years, 7 months 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 (() => { 1 (() => {
2 let mojo_; 2 let mojo_;
3 3
4 async function loadFakeBluetoothInterfaces() { 4 async function loadFakeBluetoothInterfaces() {
5 if(typeof mojo_ !== 'undefined') { 5 if(typeof mojo_ !== 'undefined') {
6 return mojo_; 6 return mojo_;
7 } 7 }
8 8
9 if (typeof loadMojoModules === 'undefined') { 9 if (typeof loadMojoModules === 'undefined') {
10 throw 'Mojo is required for this API.' 10 throw 'Mojo is required for this API.'
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // Canonicalize and convert to mojo UUIDs. 132 // Canonicalize and convert to mojo UUIDs.
133 knownServiceUUIDs.forEach((val, i, arr) => { 133 knownServiceUUIDs.forEach((val, i, arr) => {
134 knownServiceUUIDs[i] = {uuid: BluetoothUUID.getService(val)}; 134 knownServiceUUIDs[i] = {uuid: BluetoothUUID.getService(val)};
135 }); 135 });
136 136
137 await this.fake_central_ptr_.simulatePreconnectedPeripheral( 137 await this.fake_central_ptr_.simulatePreconnectedPeripheral(
138 address, name, knownServiceUUIDs); 138 address, name, knownServiceUUIDs);
139 139
140 let peripheral = this.peripherals_.get(address); 140 let peripheral = this.peripherals_.get(address);
141 if (peripheral === undefined) { 141 if (peripheral === undefined) {
142 peripheral = new FakePeripheral(address, this); 142 peripheral = new FakePeripheral(address, this.fake_central_ptr_);
143 this.peripherals_.set(address, peripheral); 143 this.peripherals_.set(address, peripheral);
144 } 144 }
145 145
146 return peripheral; 146 return peripheral;
147 } 147 }
148 } 148 }
149 149
150 class FakePeripheral { 150 class FakePeripheral {
151 constructor(address, fake_central) { 151 constructor(address, fake_central_ptr) {
152 this.address = address; 152 this.address = address;
153 this.fake_central_ = fake_central; 153 this.fake_central_ptr_ = fake_central_ptr;
154 }
155
156 // Simulates a GATT Connection request response with |code| for the
157 // peripheral. |code| could be an HCI Error Code from
158 // BT 4.2 Vol 2 Part D 1.3 List Of Error Codes or a number outside that
159 // range returned by specific platforms e.g. Android returns 0x101 to signal
160 // a GATT failure
161 // https://developer.android.com/reference/android/bluetooth/BluetoothGatt.h tml#GATT_FAILURE
162 async simulateGATTConnectionResponse({code}) {
163 await this.fake_central_ptr_.simulateGATTConnectionResponse(
164 this.address, code);
154 } 165 }
155 } 166 }
156 167
157 navigator.bluetooth.test = new FakeBluetooth(); 168 navigator.bluetooth.test = new FakeBluetooth();
158 })(); 169 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698