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

Unified Diff: content/browser/bluetooth/bluetooth_allowed_devices_map_unittest.cc

Issue 2015463004: bluetooth: Use BluetoothUUID instead of string when sending uuids (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-mojo-request-device
Patch Set: Lint Created 4 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/bluetooth/bluetooth_allowed_devices_map_unittest.cc
diff --git a/content/browser/bluetooth/bluetooth_allowed_devices_map_unittest.cc b/content/browser/bluetooth/bluetooth_allowed_devices_map_unittest.cc
index eab3493fa4ca6be7d17cdd5ec6cd8fe8fdecd8ab..b6a194fc17ec926d53805484ff8e1afc3ba40b19 100644
--- a/content/browser/bluetooth/bluetooth_allowed_devices_map_unittest.cc
+++ b/content/browser/bluetooth/bluetooth_allowed_devices_map_unittest.cc
@@ -18,11 +18,16 @@ const url::Origin kTestOrigin2(GURL("https://www.example2.com"));
const std::string kDeviceAddress1 = "00:00:00";
const std::string kDeviceAddress2 = "11:11:11";
-const char kGlucoseUUID[] = "00001808-0000-1000-8000-00805f9b34fb";
-const char kHeartRateUUID[] = "0000180d-0000-1000-8000-00805f9b34fb";
-const char kBatteryServiceUUID[] = "0000180f-0000-1000-8000-00805f9b34fb";
-const char kBloodPressureUUID[] = "00001813-0000-1000-8000-00805f9b34fb";
-const char kCyclingPowerUUID[] = "00001818-0000-1000-8000-00805f9b34fb";
+const char kGlucoseUUIDString[] = "00001808-0000-1000-8000-00805f9b34fb";
+const char kHeartRateUUIDString[] = "0000180d-0000-1000-8000-00805f9b34fb";
+const char kBatteryServiceUUIDString[] = "0000180f-0000-1000-8000-00805f9b34fb";
+const char kBloodPressureUUIDString[] = "00001813-0000-1000-8000-00805f9b34fb";
+const char kCyclingPowerUUIDString[] = "00001818-0000-1000-8000-00805f9b34fb";
+const BluetoothUUID kGlucoseUUID(kGlucoseUUIDString);
Jeffrey Yasskin 2016/05/28 04:38:06 Didn't we just get rid of these? ;-)
ortuno 2016/05/31 17:30:47 We did! But turns out we needed them hehe
+const BluetoothUUID kHeartRateUUID(kHeartRateUUIDString);
+const BluetoothUUID kBatteryServiceUUID(kBatteryServiceUUIDString);
+const BluetoothUUID kBloodPressureUUID(kBloodPressureUUIDString);
+const BluetoothUUID kCyclingPowerUUID(kCyclingPowerUUIDString);
class BluetoothAllowedDevicesMapTest : public testing::Test {
protected:
@@ -32,6 +37,22 @@ class BluetoothAllowedDevicesMapTest : public testing::Test {
~BluetoothAllowedDevicesMapTest() override {}
+ std::unique_ptr<BluetoothUUID> GetGlucoseUUID() {
Jeffrey Yasskin 2016/05/28 04:38:06 Maybe "GetGlucoseUUIDPtr()" to be clear how this i
ortuno 2016/05/31 17:30:47 Since these now return an Optional, I changed them
+ return base::WrapUnique(new BluetoothUUID(kGlucoseUUID));
Jeffrey Yasskin 2016/05/28 04:38:06 We have base::MakeUnique<BluetoothUUID>(kGlucoseUU
ortuno 2016/05/31 17:30:47 No longer needed.
+ }
+ std::unique_ptr<BluetoothUUID> GetHeartRateUUID() {
+ return base::WrapUnique(new BluetoothUUID(kHeartRateUUID));
+ }
+ std::unique_ptr<BluetoothUUID> GetBatteryServiceUUID() {
+ return base::WrapUnique(new BluetoothUUID(kBatteryServiceUUID));
+ }
+ std::unique_ptr<BluetoothUUID> GetBloodPressureUUID() {
+ return base::WrapUnique(new BluetoothUUID(kBloodPressureUUID));
+ }
+ std::unique_ptr<BluetoothUUID> GetCyclingPowerUUID() {
+ return base::WrapUnique(new BluetoothUUID(kCyclingPowerUUID));
+ }
+
blink::mojom::WebBluetoothRequestDeviceOptionsPtr empty_options_;
};
@@ -177,19 +198,27 @@ TEST_F(BluetoothAllowedDevicesMapTest, AllowedServices_OneOriginOneDevice) {
// Setup device.
blink::mojom::WebBluetoothRequestDeviceOptionsPtr options =
blink::mojom::WebBluetoothRequestDeviceOptions::New();
+
blink::mojom::WebBluetoothScanFilterPtr scanFilter1 =
blink::mojom::WebBluetoothScanFilter::New();
+ blink::mojom::WebBluetoothScanFilterPtr scanFilter1Clone =
+ blink::mojom::WebBluetoothScanFilter::New();
+
blink::mojom::WebBluetoothScanFilterPtr scanFilter2 =
blink::mojom::WebBluetoothScanFilter::New();
+ blink::mojom::WebBluetoothScanFilterPtr scanFilter2Clone =
+ blink::mojom::WebBluetoothScanFilter::New();
- scanFilter1->services.push_back(kGlucoseUUID);
- options->filters.push_back(scanFilter1.Clone());
+ scanFilter1->services.push_back(GetGlucoseUUID());
+ scanFilter1Clone->services.push_back(GetGlucoseUUID());
Jeffrey Yasskin 2016/05/28 04:38:06 The fact that we can't clone messages with unique_
ortuno 2016/05/31 17:30:47 Done. FWIW once we Onion-Soup Web Bluetooth, blink
- scanFilter2->services.push_back(kHeartRateUUID);
- options->filters.push_back(scanFilter2.Clone());
+ scanFilter2->services.push_back(GetHeartRateUUID());
+ scanFilter2Clone->services.push_back(GetHeartRateUUID());
- options->optional_services.push_back(kBatteryServiceUUID);
- options->optional_services.push_back(kHeartRateUUID);
+ options->filters.push_back(std::move(scanFilter1));
+ options->filters.push_back(std::move(scanFilter2));
+ options->optional_services.push_back(GetBatteryServiceUUID());
+ options->optional_services.push_back(GetHeartRateUUID());
// Add to map.
const std::string device_id1 =
@@ -221,8 +250,8 @@ TEST_F(BluetoothAllowedDevicesMapTest, AllowedServices_OneOriginOneDevice) {
blink::mojom::WebBluetoothRequestDeviceOptionsPtr options2 =
blink::mojom::WebBluetoothRequestDeviceOptions::New();
- options2->filters.push_back(scanFilter1.Clone());
- options2->filters.push_back(scanFilter2.Clone());
+ options2->filters.push_back(std::move(scanFilter1Clone));
+ options2->filters.push_back(std::move(scanFilter2Clone));
const std::string device_id2 =
allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options2);
@@ -255,10 +284,10 @@ TEST_F(BluetoothAllowedDevicesMapTest, AllowedServices_OneOriginTwoDevices) {
blink::mojom::WebBluetoothScanFilterPtr scanFilter1 =
blink::mojom::WebBluetoothScanFilter::New();
- scanFilter1->services.push_back(kGlucoseUUID);
+ scanFilter1->services.push_back(GetGlucoseUUID());
options1->filters.push_back(std::move(scanFilter1));
- options1->optional_services.push_back(kHeartRateUUID);
+ options1->optional_services.push_back(GetHeartRateUUID());
// Setup request for device #2.
blink::mojom::WebBluetoothRequestDeviceOptionsPtr options2 =
@@ -266,10 +295,10 @@ TEST_F(BluetoothAllowedDevicesMapTest, AllowedServices_OneOriginTwoDevices) {
blink::mojom::WebBluetoothScanFilterPtr scanFilter2 =
blink::mojom::WebBluetoothScanFilter::New();
- scanFilter2->services.push_back(kBatteryServiceUUID);
+ scanFilter2->services.push_back(GetBatteryServiceUUID());
options2->filters.push_back(std::move(scanFilter2));
- options2->optional_services.push_back(kBloodPressureUUID);
+ options2->optional_services.push_back(GetBloodPressureUUID());
// Add devices to map.
const std::string& device_id1 =
@@ -312,10 +341,10 @@ TEST_F(BluetoothAllowedDevicesMapTest, AllowedServices_TwoOriginsOneDevice) {
blink::mojom::WebBluetoothScanFilterPtr scanFilter1 =
blink::mojom::WebBluetoothScanFilter::New();
- scanFilter1->services.push_back(kGlucoseUUID);
+ scanFilter1->services.push_back(GetGlucoseUUID());
options1->filters.push_back(std::move(scanFilter1));
- options1->optional_services.push_back(kHeartRateUUID);
+ options1->optional_services.push_back(GetHeartRateUUID());
// Setup request #2 for device.
blink::mojom::WebBluetoothRequestDeviceOptionsPtr options2 =
@@ -323,10 +352,10 @@ TEST_F(BluetoothAllowedDevicesMapTest, AllowedServices_TwoOriginsOneDevice) {
blink::mojom::WebBluetoothScanFilterPtr scanFilter2 =
blink::mojom::WebBluetoothScanFilter::New();
- scanFilter2->services.push_back(kBatteryServiceUUID);
+ scanFilter2->services.push_back(GetBatteryServiceUUID());
options2->filters.push_back(std::move(scanFilter2));
- options2->optional_services.push_back(kBloodPressureUUID);
+ options2->optional_services.push_back(GetBloodPressureUUID());
// Add devices to map.
const std::string& device_id1 =
@@ -384,10 +413,10 @@ TEST_F(BluetoothAllowedDevicesMapTest, MergeServices) {
blink::mojom::WebBluetoothScanFilterPtr scanFilter1 =
blink::mojom::WebBluetoothScanFilter::New();
- scanFilter1->services.push_back(kGlucoseUUID);
+ scanFilter1->services.push_back(GetGlucoseUUID());
options1->filters.push_back(std::move(scanFilter1));
- options1->optional_services.push_back(kBatteryServiceUUID);
+ options1->optional_services.push_back(GetBatteryServiceUUID());
// Add to map.
const std::string device_id1 =
@@ -399,10 +428,10 @@ TEST_F(BluetoothAllowedDevicesMapTest, MergeServices) {
blink::mojom::WebBluetoothScanFilterPtr scanFilter2 =
blink::mojom::WebBluetoothScanFilter::New();
- scanFilter2->services.push_back(kHeartRateUUID);
+ scanFilter2->services.push_back(GetHeartRateUUID());
options2->filters.push_back(std::move(scanFilter2));
- options2->optional_services.push_back(kBloodPressureUUID);
+ options2->optional_services.push_back(GetBloodPressureUUID());
// Add to map again.
const std::string device_id2 =

Powered by Google App Engine
This is Rietveld 408576698