Bug 1449008 [wpt PR 9322] - bluetooth: web: test: Update blocklist UUID tests, a=testonly
authorOvidio Henriquez <odejesush@chromium.org>
Mon, 09 Apr 2018 21:32:42 +0000
changeset 467250 1cb51ca5e7004b25c5a3150552dbc1c7e0b7375c
parent 467249 3f0a1ed7321692654d74ee66b280fe4ce0e699b9
child 467251 2eb0e12efd4516aa869c81c17f78660b0f0d04f0
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1449008, 509038, 894738, 547588
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1449008 [wpt PR 9322] - bluetooth: web: test: Update blocklist UUID tests, a=testonly Automatic update from web-platform-testsbluetooth: web: test: Update blocklist UUID tests This change updates the blocklisted UUID tests to use the Web Bluetooth Test API. This will allow the test to be migrated into wpt/. BUG=509038 Change-Id: I72acd10e5aabc4c03f955dc4c7b2a8620930cc2d Reviewed-on: https://chromium-review.googlesource.com/894738 Commit-Queue: Ovidio Henriquez <odejesush@chromium.org> Reviewed-by: Giovanni Ortuño Urquidi <ortuno@chromium.org> Cr-Commit-Position: refs/heads/master@{#547588} wpt-commits: 02bf90086b80366a87edee52090a62896dd2391d wpt-pr: 9322 wpt-commits: 02bf90086b80366a87edee52090a62896dd2391d wpt-pr: 9322
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/bluetooth/resources/bluetooth-helpers.js
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -402632,17 +402632,17 @@
    "2bf20db77582e6df2674dd0a5cf444d630b3b999",
    "testharness"
   ],
   "bluetooth/requestDevice/single-filter-single-service.https.html": [
    "f147182b894cbb0f338111b146dfa16193610265",
    "testharness"
   ],
   "bluetooth/resources/bluetooth-helpers.js": [
-   "9d2b233c511627f6a4fe93bdaf16ba28c4a6ead9",
+   "f19d8ab872de44f50c37aac3e3ad97ab0e502b59",
    "support"
   ],
   "bluetooth/resources/health-thermometer-iframe.html": [
    "f175a62907e65c03e326832449b0b8e3276387d8",
    "support"
   ],
   "bluetooth/script-tests/base_test_html.template": [
    "abe5c81d5d9be9b0c6069ba0a465ca3efc24b442",
--- a/testing/web-platform/tests/bluetooth/resources/bluetooth-helpers.js
+++ b/testing/web-platform/tests/bluetooth/resources/bluetooth-helpers.js
@@ -86,16 +86,18 @@ var blocklist_test_service_uuid = "611c9
 var request_disconnection_service_uuid = "01d7d889-7451-419f-aeb8-d65e7b9277af";
 // Characteristics:
 var blocklist_exclude_reads_characteristic_uuid =
   "bad1c9a2-9a5b-4015-8b60-1579bbbf2135";
 var request_disconnection_characteristic_uuid =
   "01d7d88a-7451-419f-aeb8-d65e7b9277af";
 // Descriptors:
 var blocklist_test_descriptor_uuid = "bad2ddcf-60db-45cd-bef9-fd72b153cf7c";
+var blocklist_exclude_reads_descriptor_uuid =
+    "bad3ec61-3cc3-4954-9702-7977df514114";
 
 // Sometimes we need to test that using either the name, alias, or UUID
 // produces the same result. The following objects help us do that.
 var generic_access = {
   alias: 0x1800,
   name: 'generic_access',
   uuid: '00001800-0000-1000-8000-00805f9b34fb'
 };
@@ -669,16 +671,172 @@ function getConnectedHealthThermometerDe
       code: HCI_SUCCESS,
     }))
     .then(() => populateHealthThermometerFakes(fake_peripheral))
     .then(_ => fakes = _)
     .then(() => device.gatt.connect())
     .then(() => Object.assign({device}, fakes));
 }
 
+// Returns an object containing a BluetoothDevice discovered using |options|,
+// its corresponding FakePeripheral and FakeRemoteGATTServices.
+// The simulated device is called 'Blocklist Device' and it has one known
+// service UUIDs |blocklist_test_service_uuid| which
+// correspond to a service with the same UUID. The
+// |blocklist_test_service_uuid| service contains two characteristics:
+//   - |blocklist_exclude_reads_characteristic_uuid| (read, write)
+//   - 'gap.peripheral_privacy_flag' (read, write)
+// The 'gap.peripheral_privacy_flag' characteristic contains three descriptors:
+//   - |blocklist_test_descriptor_uuid|
+//   - |blocklist_exclude_reads_descriptor_uuid|
+//   - 'gatt.client_characteristic_configuration'
+// These are special UUIDs that have been added to the blocklist found at
+// https://github.com/WebBluetoothCG/registries/blob/master/gatt_blocklist.txt
+// There are also test UUIDs that have been added to the test environment which
+// other implementations should add as test UUIDs as well.
+// The device has been connected to and its attributes are ready to be
+// discovered.
+function getBlocklistDevice(
+    options = {filters: [{services: [blocklist_test_service_uuid]}]}) {
+  let device, fake_peripheral, fake_blocklist_test_service,
+      fake_blocklist_exclude_reads_characteristic,
+      fake_blocklist_exclude_writes_characteristic,
+      fake_blocklist_descriptor,
+      fake_blocklist_exclude_reads_descriptor,
+      fake_blocklist_exclude_writes_descriptor;
+  return setUpPreconnectedDevice({
+    address: '11:11:11:11:11:11',
+    name: 'Blocklist Device',
+    knownServiceUUIDs: ['generic_access', blocklist_test_service_uuid],
+  })
+      .then(_ => fake_peripheral = _)
+      .then(() => requestDeviceWithTrustedClick(options))
+      .then(_ => device = _)
+      .then(() => fake_peripheral.setNextGATTConnectionResponse({
+        code: HCI_SUCCESS,
+      }))
+      .then(() => device.gatt.connect())
+      .then(() => fake_peripheral.addFakeService({
+        uuid: blocklist_test_service_uuid,
+      }))
+      .then(_ => fake_blocklist_test_service = _)
+      .then(() => fake_blocklist_test_service.addFakeCharacteristic({
+        uuid: blocklist_exclude_reads_characteristic_uuid,
+        properties: ['read', 'write'],
+      }))
+      .then(_ => fake_blocklist_exclude_reads_characteristic = _)
+      .then(() => fake_blocklist_test_service.addFakeCharacteristic({
+        uuid: 'gap.peripheral_privacy_flag',
+        properties: ['read', 'write'],
+      }))
+      .then(_ => fake_blocklist_exclude_writes_characteristic = _)
+      .then(() => fake_blocklist_exclude_writes_characteristic
+          .addFakeDescriptor({uuid: blocklist_test_descriptor_uuid}))
+      .then(_ => fake_blocklist_descriptor = _)
+      .then(() => fake_blocklist_exclude_writes_characteristic
+          .addFakeDescriptor({uuid: blocklist_exclude_reads_descriptor_uuid}))
+      .then(_ => fake_blocklist_exclude_reads_descriptor = _)
+      .then(() => fake_blocklist_exclude_writes_characteristic
+          .addFakeDescriptor({
+            uuid: 'gatt.client_characteristic_configuration'
+          }))
+      .then(_ => fake_blocklist_exclude_writes_descriptor = _)
+      .then(() => fake_peripheral.setNextGATTDiscoveryResponse({
+        code: HCI_SUCCESS,
+      }))
+      .then(() => ({
+        device,
+        fake_peripheral,
+        fake_blocklist_test_service,
+        fake_blocklist_exclude_reads_characteristic,
+        fake_blocklist_exclude_writes_characteristic,
+        fake_blocklist_descriptor,
+        fake_blocklist_exclude_reads_descriptor,
+        fake_blocklist_exclude_writes_descriptor,
+      }));
+}
+
+// Returns an object containing a Blocklist Test BluetoothRemoveGattService and
+// its corresponding FakeRemoteGATTService.
+function getBlocklistTestService() {
+  let result;
+  return getBlocklistDevice()
+      .then(_ => result = _)
+      .then(() =>
+          result.device.gatt.getPrimaryService(blocklist_test_service_uuid))
+      .then(service => Object.assign(result, {
+        service,
+        fake_service: result.fake_blocklist_test_service,
+      }));
+}
+
+// Returns an object containing a blocklisted BluetoothRemoteGATTCharacteristic
+// that excludes reads and its corresponding FakeRemoteGATTCharacteristic.
+function getBlocklistExcludeReadsCharacteristic() {
+  let result, fake_characteristic;
+  return getBlocklistTestService()
+      .then(_ => result = _)
+      .then(() => result.service.getCharacteristic(
+          blocklist_exclude_reads_characteristic_uuid))
+      .then(characteristic =>
+          Object.assign(
+              result, {
+                characteristic,
+                fake_characteristic:
+                    result.fake_blocklist_exclude_reads_characteristic
+              }));
+}
+
+// Returns an object containing a blocklisted BluetoothRemoteGATTCharacteristic
+// that excludes writes and its corresponding FakeRemoteGATTCharacteristic.
+function getBlocklistExcludeWritesCharacteristic() {
+  let result, fake_characteristic;
+  return getBlocklistTestService()
+      .then(_ => result = _)
+      .then(() => result.service.getCharacteristic(
+          'gap.peripheral_privacy_flag'))
+      .then(characteristic =>
+          Object.assign(
+              result, {
+                characteristic,
+                fake_characteristic:
+                    result.fake_blocklist_exclude_writes_characteristic
+              }));
+}
+
+// Returns an object containing a blocklisted BluetoothRemoteGATTDescriptor that
+// excludes reads and its corresponding FakeRemoteGATTDescriptor.
+function getBlocklistExcludeReadsDescriptor() {
+  let result;
+  return getBlocklistExcludeWritesCharacteristic()
+      .then(_ => result = _)
+      .then(() => result.characteristic.getDescriptor(
+          blocklist_exclude_reads_descriptor_uuid))
+      .then(descriptor => Object.assign(
+          result, {
+            descriptor,
+            fake_descriptor: result.fake_blocklist_exclude_reads_descriptor
+          }));
+}
+
+// Returns an object containing a blocklisted BluetoothRemoteGATTDescriptor that
+// excludes writes and its corresponding FakeRemoteGATTDescriptor.
+function getBlocklistExcludeWritesDescriptor() {
+  let result;
+  return getBlocklistExcludeWritesCharacteristic()
+      .then(_ => result = _)
+      .then(() => result.characteristic.getDescriptor(
+          'gatt.client_characteristic_configuration'))
+      .then(descriptor => Object.assign(
+          result, {
+            descriptor: descriptor,
+            fake_descriptor: result.fake_blocklist_exclude_writes_descriptor,
+          }));
+}
+
 // Returns the same device and fake peripheral as getHealthThermometerDevice()
 // after another frame (an iframe we insert) discovered the device,
 // connected to it and discovered its services.
 function getHealthThermometerDeviceWithServicesDiscovered(options) {
   let device, fake_peripheral, fakes;
   let iframe = document.createElement('iframe');
   return setUpConnectableHealthThermometerDevice()
     .then(_ => fake_peripheral = _)