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

Unified Diff: LayoutTests/bluetooth/requestDevice.html

Issue 1174843002: Add tests for RequestDeviceOptions and clean up. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@pinned
Patch Set: Comment how the ScanFilterCheckingAdapter test works Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/bluetooth/readValue.html ('k') | public/platform/modules/bluetooth/WebBluetooth.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/bluetooth/requestDevice.html
diff --git a/LayoutTests/bluetooth/requestDevice.html b/LayoutTests/bluetooth/requestDevice.html
index 932d985dde5c7bb6797c71d9e4fa636634f0a257..b0a5ee9a6e5c4b72470c27b4b3dcf2f0820a9bee 100644
--- a/LayoutTests/bluetooth/requestDevice.html
+++ b/LayoutTests/bluetooth/requestDevice.html
@@ -38,4 +38,58 @@ sequential_promise_test(function() {
assert_equals(device.constructor.name, "BluetoothDevice");
});
}, 'Mock will resolve.');
+
+sequential_promise_test(function() {
+ testRunner.setBluetoothMockDataSet('ScanFilterCheckingAdapter');
+ // The work of this test is done in the ScanFilterCheckingAdapter. It asserts
+ // that this requestDevice() call tells the platform to scan for only devices
+ // that include the Battery, Glucose, or Heart Rate services.
+ return navigator.bluetooth.requestDevice({
+ filters: [
+ {services: [batteryServiceUuid]},
+ {services: [glucoseServiceUuid, heartRateServiceUuid]}
+ ],
+ // The optionalServices shouldn't affect the platform's scan.
+ optionalServices: [genericAccessServiceUuid]
+ });
+}, 'Filters restrict the platform\'s Bluetooth scan.');
+
+sequential_promise_test(function() {
+ testRunner.setBluetoothMockDataSet('MultiDeviceAdapter');
+ return navigator.bluetooth.requestDevice({
+ filters: [{services: [glucoseServiceUuid]}]
ortuno 2015/06/18 22:04:42 If you pass something other than a string, say an
+ }).then(function(device) {
+ assert_equals(device.name, "Glucose Device");
+ });
+}, 'Simple filter selects matching device.');
+
+sequential_promise_test(function() {
+ testRunner.setBluetoothMockDataSet('MultiDeviceAdapter');
+ return navigator.bluetooth.requestDevice({
+ filters: [{services: [genericAccessServiceUuid, heartRateServiceUuid]}]
+ }).then(function(device) {
+ assert_equals(device.name, "Heart Rate Device");
+ });
+}, 'Filter with 2 services returns a matching device.');
+
+sequential_promise_test(function() {
+ testRunner.setBluetoothMockDataSet('MultiDeviceAdapter');
+ return navigator.bluetooth.requestDevice({
+ filters: [{services: [batteryServiceUuid]},
+ {services: [heartRateServiceUuid]}]
+ }).then(function(device) {
+ assert_equals(device.name, "Heart Rate Device");
+ });
+}, 'An extra filter doesn\'t prevent matching.');
+
+sequential_promise_test(function() {
+ testRunner.setBluetoothMockDataSet('MultiDeviceAdapter');
+ // Both devices support the Generic Access service, but things need to
+ // support both services to pass the filter, and neither has a Battery
+ // service.
+ return assert_promise_rejects(navigator.bluetooth.requestDevice({
+ filters: [{services: [genericAccessServiceUuid, batteryServiceUuid]}]
+ }), 'NotFoundError');
+}, 'Too-strict filters do prevent matching.');
+
</script>
« no previous file with comments | « LayoutTests/bluetooth/readValue.html ('k') | public/platform/modules/bluetooth/WebBluetooth.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698