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

Unified Diff: content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h

Issue 2014473002: bluetooth: Web Bluetooth can filter by empty device names, doesn't leak MACs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bt-GetNameOrEmpty-
Patch Set: Correct null handling in renderer; Null and Empty Named fakes & tests. Created 4 years, 5 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
Index: content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h
diff --git a/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h b/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h
index 362960866c5fc6a079a8aec67f43b24677ddf80c..17f6af1052b1a5a556e53582841bf8c8a610e31e 100644
--- a/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h
+++ b/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h
@@ -182,6 +182,39 @@ class LayoutTestBluetoothAdapterProvider {
static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>>
GetHeartRateAdapter();
+ // |GetEmptyNameHeartRateAdapter|
+ // Inherits from |EmptyAdapter|
+ // Internal Structure:
+ // - Heart Rate Device
+ // - UUIDs:
+ // - Generic Access UUID (0x1800)
+ // - Heart Rate UUID (0x180d)
+ // - Services:
+ // - Generic Access Service - Characteristics as described in
+ // GetGenericAccessService.
+ // - gap.device_name returns an empty string.
+ // - Heart Rate Service - Characteristics as described in
+ // GetHeartRateService.
+ static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>>
+ GetEmptyNameHeartRateAdapter();
+
+ // |GetNoNameHeartRateAdapter|
+ // Inherits from |EmptyAdapter|
+ // Internal Structure:
+ // - Heart Rate Device
+ // - GetName returns base::null_opt.
+ // - UUIDs:
+ // - Generic Access UUID (0x1800)
+ // - Heart Rate UUID (0x180d)
+ // - Services:
+ // - Generic Access Service - Characteristics as described in
+ // GetGenericAccessService.
+ // - gap.device_name returns an empty string.
+ // - Heart Rate Service - Characteristics as described in
+ // GetHeartRateService.
+ static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>>
+ GetNoNameHeartRateAdapter();
+
// |TwoHeartRateServicesAdapter|
// Inherits from |EmptyAdapter|
// Internal Structure:
@@ -371,10 +404,21 @@ class LayoutTestBluetoothAdapterProvider {
// BluetoothDevice::ConnectErrorCode::ERROR_UNSUPPORTED_DEVICE.
static std::unique_ptr<testing::NiceMock<device::MockBluetoothDevice>>
GetBaseDevice(device::MockBluetoothAdapter* adapter,
- const std::string& device_name = "Base Device",
+ const base::Optional<std::string>& device_name =
+ base::Optional<std::string>("Base Device"),
device::BluetoothDevice::UUIDList uuids =
device::BluetoothDevice::UUIDList(),
const std::string& address = "00:00:00:00:00:00");
+ // Version without base::optional parameters, for simpler call sites:
+ static std::unique_ptr<testing::NiceMock<device::MockBluetoothDevice>>
ortuno 2016/07/31 18:00:05 In the base::Optional documentation it says that w
scheib 2016/08/02 03:24:33 Done.
+ GetBaseDevice(device::MockBluetoothAdapter* adapter,
+ const std::string& device_name,
+ device::BluetoothDevice::UUIDList uuids =
+ device::BluetoothDevice::UUIDList(),
+ const std::string& address = "00:00:00:00:00:00") {
+ return GetBaseDevice(adapter, base::make_optional(device_name), uuids,
+ address);
+ }
// |BatteryDevice|
// Inherits from |BaseDevice|(adapter, "Battery Device", uuids,
@@ -410,9 +454,20 @@ class LayoutTestBluetoothAdapterProvider {
static std::unique_ptr<testing::NiceMock<device::MockBluetoothDevice>>
GetConnectableDevice(
device::MockBluetoothAdapter* adapter,
- const std::string& device_name = "Connectable Device",
+ const base::Optional<std::string>& device_name =
+ base::Optional<std::string>("Connectable Device"),
device::BluetoothDevice::UUIDList = device::BluetoothDevice::UUIDList(),
const std::string& address = "00:00:00:00:00:00");
+ // Version without base::optional parameters, for simpler call sites:
+ static std::unique_ptr<testing::NiceMock<device::MockBluetoothDevice>>
+ GetConnectableDevice(device::MockBluetoothAdapter* adapter,
+ const std::string& device_name,
+ device::BluetoothDevice::UUIDList uuids =
+ device::BluetoothDevice::UUIDList(),
+ const std::string& address = "00:00:00:00:00:00") {
+ return GetConnectableDevice(adapter, base::make_optional(device_name),
+ uuids, address);
+ }
// |UnconnectableDevice|
// Inherits from |BaseDevice|(adapter, device_name)
@@ -438,7 +493,9 @@ class LayoutTestBluetoothAdapterProvider {
// None. Each user of the HeartRateDevice is in charge of adding the
// relevant services, characteristics and descriptors.
static std::unique_ptr<testing::NiceMock<device::MockBluetoothDevice>>
- GetHeartRateDevice(device::MockBluetoothAdapter* adapter);
+ GetHeartRateDevice(device::MockBluetoothAdapter* adapter,
+ const base::Optional<std::string>& device_name =
+ base::Optional<std::string>("Heart Rate Device"));
// Services

Powered by Google App Engine
This is Rietveld 408576698