Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/bluetooth/bluetooth_allowed_devices_map.h" | 5 #include "content/browser/bluetooth/bluetooth_allowed_devices_map.h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "url/gurl.h" | 9 #include "url/gurl.h" |
| 10 | 10 |
| 11 using device::BluetoothUUID; | 11 using device::BluetoothUUID; |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 namespace { | 14 namespace { |
| 15 const url::Origin kTestOrigin1(GURL("https://www.example1.com")); | 15 const url::Origin kTestOrigin1(GURL("https://www.example1.com")); |
| 16 const url::Origin kTestOrigin2(GURL("https://www.example2.com")); | 16 const url::Origin kTestOrigin2(GURL("https://www.example2.com")); |
| 17 | 17 |
| 18 const std::string kDeviceAddress1 = "00:00:00"; | 18 const std::string kDeviceAddress1 = "00:00:00"; |
| 19 const std::string kDeviceAddress2 = "11:11:11"; | 19 const std::string kDeviceAddress2 = "11:11:11"; |
| 20 | 20 |
| 21 const char kGlucoseUUID[] = "00001808-0000-1000-8000-00805f9b34fb"; | 21 const char kGlucoseUUIDString[] = "00001808-0000-1000-8000-00805f9b34fb"; |
| 22 const char kHeartRateUUID[] = "0000180d-0000-1000-8000-00805f9b34fb"; | 22 const char kHeartRateUUIDString[] = "0000180d-0000-1000-8000-00805f9b34fb"; |
| 23 const char kBatteryServiceUUID[] = "0000180f-0000-1000-8000-00805f9b34fb"; | 23 const char kBatteryServiceUUIDString[] = "0000180f-0000-1000-8000-00805f9b34fb"; |
| 24 const char kBloodPressureUUID[] = "00001813-0000-1000-8000-00805f9b34fb"; | 24 const char kBloodPressureUUIDString[] = "00001813-0000-1000-8000-00805f9b34fb"; |
| 25 const char kCyclingPowerUUID[] = "00001818-0000-1000-8000-00805f9b34fb"; | 25 const char kCyclingPowerUUIDString[] = "00001818-0000-1000-8000-00805f9b34fb"; |
| 26 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
| |
| 27 const BluetoothUUID kHeartRateUUID(kHeartRateUUIDString); | |
| 28 const BluetoothUUID kBatteryServiceUUID(kBatteryServiceUUIDString); | |
| 29 const BluetoothUUID kBloodPressureUUID(kBloodPressureUUIDString); | |
| 30 const BluetoothUUID kCyclingPowerUUID(kCyclingPowerUUIDString); | |
| 26 | 31 |
| 27 class BluetoothAllowedDevicesMapTest : public testing::Test { | 32 class BluetoothAllowedDevicesMapTest : public testing::Test { |
| 28 protected: | 33 protected: |
| 29 BluetoothAllowedDevicesMapTest() { | 34 BluetoothAllowedDevicesMapTest() { |
| 30 empty_options_ = blink::mojom::WebBluetoothRequestDeviceOptions::New(); | 35 empty_options_ = blink::mojom::WebBluetoothRequestDeviceOptions::New(); |
| 31 } | 36 } |
| 32 | 37 |
| 33 ~BluetoothAllowedDevicesMapTest() override {} | 38 ~BluetoothAllowedDevicesMapTest() override {} |
| 34 | 39 |
| 40 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
| |
| 41 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.
| |
| 42 } | |
| 43 std::unique_ptr<BluetoothUUID> GetHeartRateUUID() { | |
| 44 return base::WrapUnique(new BluetoothUUID(kHeartRateUUID)); | |
| 45 } | |
| 46 std::unique_ptr<BluetoothUUID> GetBatteryServiceUUID() { | |
| 47 return base::WrapUnique(new BluetoothUUID(kBatteryServiceUUID)); | |
| 48 } | |
| 49 std::unique_ptr<BluetoothUUID> GetBloodPressureUUID() { | |
| 50 return base::WrapUnique(new BluetoothUUID(kBloodPressureUUID)); | |
| 51 } | |
| 52 std::unique_ptr<BluetoothUUID> GetCyclingPowerUUID() { | |
| 53 return base::WrapUnique(new BluetoothUUID(kCyclingPowerUUID)); | |
| 54 } | |
| 55 | |
| 35 blink::mojom::WebBluetoothRequestDeviceOptionsPtr empty_options_; | 56 blink::mojom::WebBluetoothRequestDeviceOptionsPtr empty_options_; |
| 36 }; | 57 }; |
| 37 | 58 |
| 38 } // namespace | 59 } // namespace |
| 39 | 60 |
| 40 TEST_F(BluetoothAllowedDevicesMapTest, UniqueOriginNotSupported) { | 61 TEST_F(BluetoothAllowedDevicesMapTest, UniqueOriginNotSupported) { |
| 41 BluetoothAllowedDevicesMap allowed_devices_map; | 62 BluetoothAllowedDevicesMap allowed_devices_map; |
| 42 | 63 |
| 43 EXPECT_DEATH_IF_SUPPORTED(allowed_devices_map.AddDevice( | 64 EXPECT_DEATH_IF_SUPPORTED(allowed_devices_map.AddDevice( |
| 44 url::Origin(), kDeviceAddress1, empty_options_), | 65 url::Origin(), kDeviceAddress1, empty_options_), |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 EXPECT_EQ(base::EmptyString(), allowed_devices_map.GetDeviceAddress( | 191 EXPECT_EQ(base::EmptyString(), allowed_devices_map.GetDeviceAddress( |
| 171 kTestOrigin1, kDeviceAddress1)); | 192 kTestOrigin1, kDeviceAddress1)); |
| 172 } | 193 } |
| 173 | 194 |
| 174 TEST_F(BluetoothAllowedDevicesMapTest, AllowedServices_OneOriginOneDevice) { | 195 TEST_F(BluetoothAllowedDevicesMapTest, AllowedServices_OneOriginOneDevice) { |
| 175 BluetoothAllowedDevicesMap allowed_devices_map; | 196 BluetoothAllowedDevicesMap allowed_devices_map; |
| 176 | 197 |
| 177 // Setup device. | 198 // Setup device. |
| 178 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options = | 199 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options = |
| 179 blink::mojom::WebBluetoothRequestDeviceOptions::New(); | 200 blink::mojom::WebBluetoothRequestDeviceOptions::New(); |
| 201 | |
| 180 blink::mojom::WebBluetoothScanFilterPtr scanFilter1 = | 202 blink::mojom::WebBluetoothScanFilterPtr scanFilter1 = |
| 181 blink::mojom::WebBluetoothScanFilter::New(); | 203 blink::mojom::WebBluetoothScanFilter::New(); |
| 204 blink::mojom::WebBluetoothScanFilterPtr scanFilter1Clone = | |
| 205 blink::mojom::WebBluetoothScanFilter::New(); | |
| 206 | |
| 182 blink::mojom::WebBluetoothScanFilterPtr scanFilter2 = | 207 blink::mojom::WebBluetoothScanFilterPtr scanFilter2 = |
| 183 blink::mojom::WebBluetoothScanFilter::New(); | 208 blink::mojom::WebBluetoothScanFilter::New(); |
| 209 blink::mojom::WebBluetoothScanFilterPtr scanFilter2Clone = | |
| 210 blink::mojom::WebBluetoothScanFilter::New(); | |
| 184 | 211 |
| 185 scanFilter1->services.push_back(kGlucoseUUID); | 212 scanFilter1->services.push_back(GetGlucoseUUID()); |
| 186 options->filters.push_back(scanFilter1.Clone()); | 213 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
| |
| 187 | 214 |
| 188 scanFilter2->services.push_back(kHeartRateUUID); | 215 scanFilter2->services.push_back(GetHeartRateUUID()); |
| 189 options->filters.push_back(scanFilter2.Clone()); | 216 scanFilter2Clone->services.push_back(GetHeartRateUUID()); |
| 190 | 217 |
| 191 options->optional_services.push_back(kBatteryServiceUUID); | 218 options->filters.push_back(std::move(scanFilter1)); |
| 192 options->optional_services.push_back(kHeartRateUUID); | 219 options->filters.push_back(std::move(scanFilter2)); |
| 220 options->optional_services.push_back(GetBatteryServiceUUID()); | |
| 221 options->optional_services.push_back(GetHeartRateUUID()); | |
| 193 | 222 |
| 194 // Add to map. | 223 // Add to map. |
| 195 const std::string device_id1 = | 224 const std::string device_id1 = |
| 196 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options); | 225 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options); |
| 197 | 226 |
| 198 // Access allowed services. | 227 // Access allowed services. |
| 199 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( | 228 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( |
| 200 kTestOrigin1, device_id1, kGlucoseUUID)); | 229 kTestOrigin1, device_id1, kGlucoseUUID)); |
| 201 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( | 230 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( |
| 202 kTestOrigin1, device_id1, kHeartRateUUID)); | 231 kTestOrigin1, device_id1, kHeartRateUUID)); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 214 kTestOrigin1, device_id1, kGlucoseUUID)); | 243 kTestOrigin1, device_id1, kGlucoseUUID)); |
| 215 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService( | 244 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService( |
| 216 kTestOrigin1, device_id1, kHeartRateUUID)); | 245 kTestOrigin1, device_id1, kHeartRateUUID)); |
| 217 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService( | 246 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService( |
| 218 kTestOrigin1, device_id1, kBatteryServiceUUID)); | 247 kTestOrigin1, device_id1, kBatteryServiceUUID)); |
| 219 | 248 |
| 220 // Add device back. | 249 // Add device back. |
| 221 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options2 = | 250 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options2 = |
| 222 blink::mojom::WebBluetoothRequestDeviceOptions::New(); | 251 blink::mojom::WebBluetoothRequestDeviceOptions::New(); |
| 223 | 252 |
| 224 options2->filters.push_back(scanFilter1.Clone()); | 253 options2->filters.push_back(std::move(scanFilter1Clone)); |
| 225 options2->filters.push_back(scanFilter2.Clone()); | 254 options2->filters.push_back(std::move(scanFilter2Clone)); |
| 226 | 255 |
| 227 const std::string device_id2 = | 256 const std::string device_id2 = |
| 228 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options2); | 257 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options2); |
| 229 | 258 |
| 230 // Access allowed services. | 259 // Access allowed services. |
| 231 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( | 260 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( |
| 232 kTestOrigin1, device_id2, kGlucoseUUID)); | 261 kTestOrigin1, device_id2, kGlucoseUUID)); |
| 233 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( | 262 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( |
| 234 kTestOrigin1, device_id2, kHeartRateUUID)); | 263 kTestOrigin1, device_id2, kHeartRateUUID)); |
| 235 | 264 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 248 | 277 |
| 249 TEST_F(BluetoothAllowedDevicesMapTest, AllowedServices_OneOriginTwoDevices) { | 278 TEST_F(BluetoothAllowedDevicesMapTest, AllowedServices_OneOriginTwoDevices) { |
| 250 BluetoothAllowedDevicesMap allowed_devices_map; | 279 BluetoothAllowedDevicesMap allowed_devices_map; |
| 251 | 280 |
| 252 // Setup request for device #1. | 281 // Setup request for device #1. |
| 253 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options1 = | 282 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options1 = |
| 254 blink::mojom::WebBluetoothRequestDeviceOptions::New(); | 283 blink::mojom::WebBluetoothRequestDeviceOptions::New(); |
| 255 blink::mojom::WebBluetoothScanFilterPtr scanFilter1 = | 284 blink::mojom::WebBluetoothScanFilterPtr scanFilter1 = |
| 256 blink::mojom::WebBluetoothScanFilter::New(); | 285 blink::mojom::WebBluetoothScanFilter::New(); |
| 257 | 286 |
| 258 scanFilter1->services.push_back(kGlucoseUUID); | 287 scanFilter1->services.push_back(GetGlucoseUUID()); |
| 259 options1->filters.push_back(std::move(scanFilter1)); | 288 options1->filters.push_back(std::move(scanFilter1)); |
| 260 | 289 |
| 261 options1->optional_services.push_back(kHeartRateUUID); | 290 options1->optional_services.push_back(GetHeartRateUUID()); |
| 262 | 291 |
| 263 // Setup request for device #2. | 292 // Setup request for device #2. |
| 264 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options2 = | 293 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options2 = |
| 265 blink::mojom::WebBluetoothRequestDeviceOptions::New(); | 294 blink::mojom::WebBluetoothRequestDeviceOptions::New(); |
| 266 blink::mojom::WebBluetoothScanFilterPtr scanFilter2 = | 295 blink::mojom::WebBluetoothScanFilterPtr scanFilter2 = |
| 267 blink::mojom::WebBluetoothScanFilter::New(); | 296 blink::mojom::WebBluetoothScanFilter::New(); |
| 268 | 297 |
| 269 scanFilter2->services.push_back(kBatteryServiceUUID); | 298 scanFilter2->services.push_back(GetBatteryServiceUUID()); |
| 270 options2->filters.push_back(std::move(scanFilter2)); | 299 options2->filters.push_back(std::move(scanFilter2)); |
| 271 | 300 |
| 272 options2->optional_services.push_back(kBloodPressureUUID); | 301 options2->optional_services.push_back(GetBloodPressureUUID()); |
| 273 | 302 |
| 274 // Add devices to map. | 303 // Add devices to map. |
| 275 const std::string& device_id1 = | 304 const std::string& device_id1 = |
| 276 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options1); | 305 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options1); |
| 277 const std::string& device_id2 = | 306 const std::string& device_id2 = |
| 278 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress2, options2); | 307 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress2, options2); |
| 279 | 308 |
| 280 // Access allowed services. | 309 // Access allowed services. |
| 281 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( | 310 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( |
| 282 kTestOrigin1, device_id1, kGlucoseUUID)); | 311 kTestOrigin1, device_id1, kGlucoseUUID)); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 305 } | 334 } |
| 306 | 335 |
| 307 TEST_F(BluetoothAllowedDevicesMapTest, AllowedServices_TwoOriginsOneDevice) { | 336 TEST_F(BluetoothAllowedDevicesMapTest, AllowedServices_TwoOriginsOneDevice) { |
| 308 BluetoothAllowedDevicesMap allowed_devices_map; | 337 BluetoothAllowedDevicesMap allowed_devices_map; |
| 309 // Setup request #1 for device. | 338 // Setup request #1 for device. |
| 310 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options1 = | 339 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options1 = |
| 311 blink::mojom::WebBluetoothRequestDeviceOptions::New(); | 340 blink::mojom::WebBluetoothRequestDeviceOptions::New(); |
| 312 blink::mojom::WebBluetoothScanFilterPtr scanFilter1 = | 341 blink::mojom::WebBluetoothScanFilterPtr scanFilter1 = |
| 313 blink::mojom::WebBluetoothScanFilter::New(); | 342 blink::mojom::WebBluetoothScanFilter::New(); |
| 314 | 343 |
| 315 scanFilter1->services.push_back(kGlucoseUUID); | 344 scanFilter1->services.push_back(GetGlucoseUUID()); |
| 316 options1->filters.push_back(std::move(scanFilter1)); | 345 options1->filters.push_back(std::move(scanFilter1)); |
| 317 | 346 |
| 318 options1->optional_services.push_back(kHeartRateUUID); | 347 options1->optional_services.push_back(GetHeartRateUUID()); |
| 319 | 348 |
| 320 // Setup request #2 for device. | 349 // Setup request #2 for device. |
| 321 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options2 = | 350 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options2 = |
| 322 blink::mojom::WebBluetoothRequestDeviceOptions::New(); | 351 blink::mojom::WebBluetoothRequestDeviceOptions::New(); |
| 323 blink::mojom::WebBluetoothScanFilterPtr scanFilter2 = | 352 blink::mojom::WebBluetoothScanFilterPtr scanFilter2 = |
| 324 blink::mojom::WebBluetoothScanFilter::New(); | 353 blink::mojom::WebBluetoothScanFilter::New(); |
| 325 | 354 |
| 326 scanFilter2->services.push_back(kBatteryServiceUUID); | 355 scanFilter2->services.push_back(GetBatteryServiceUUID()); |
| 327 options2->filters.push_back(std::move(scanFilter2)); | 356 options2->filters.push_back(std::move(scanFilter2)); |
| 328 | 357 |
| 329 options2->optional_services.push_back(kBloodPressureUUID); | 358 options2->optional_services.push_back(GetBloodPressureUUID()); |
| 330 | 359 |
| 331 // Add devices to map. | 360 // Add devices to map. |
| 332 const std::string& device_id1 = | 361 const std::string& device_id1 = |
| 333 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options1); | 362 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options1); |
| 334 const std::string& device_id2 = | 363 const std::string& device_id2 = |
| 335 allowed_devices_map.AddDevice(kTestOrigin2, kDeviceAddress1, options2); | 364 allowed_devices_map.AddDevice(kTestOrigin2, kDeviceAddress1, options2); |
| 336 | 365 |
| 337 // Access allowed services. | 366 // Access allowed services. |
| 338 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( | 367 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( |
| 339 kTestOrigin1, device_id1, kGlucoseUUID)); | 368 kTestOrigin1, device_id1, kGlucoseUUID)); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 | 406 |
| 378 TEST_F(BluetoothAllowedDevicesMapTest, MergeServices) { | 407 TEST_F(BluetoothAllowedDevicesMapTest, MergeServices) { |
| 379 BluetoothAllowedDevicesMap allowed_devices_map; | 408 BluetoothAllowedDevicesMap allowed_devices_map; |
| 380 | 409 |
| 381 // Setup first request. | 410 // Setup first request. |
| 382 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options1 = | 411 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options1 = |
| 383 blink::mojom::WebBluetoothRequestDeviceOptions::New(); | 412 blink::mojom::WebBluetoothRequestDeviceOptions::New(); |
| 384 blink::mojom::WebBluetoothScanFilterPtr scanFilter1 = | 413 blink::mojom::WebBluetoothScanFilterPtr scanFilter1 = |
| 385 blink::mojom::WebBluetoothScanFilter::New(); | 414 blink::mojom::WebBluetoothScanFilter::New(); |
| 386 | 415 |
| 387 scanFilter1->services.push_back(kGlucoseUUID); | 416 scanFilter1->services.push_back(GetGlucoseUUID()); |
| 388 options1->filters.push_back(std::move(scanFilter1)); | 417 options1->filters.push_back(std::move(scanFilter1)); |
| 389 | 418 |
| 390 options1->optional_services.push_back(kBatteryServiceUUID); | 419 options1->optional_services.push_back(GetBatteryServiceUUID()); |
| 391 | 420 |
| 392 // Add to map. | 421 // Add to map. |
| 393 const std::string device_id1 = | 422 const std::string device_id1 = |
| 394 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options1); | 423 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options1); |
| 395 | 424 |
| 396 // Setup second request. | 425 // Setup second request. |
| 397 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options2 = | 426 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options2 = |
| 398 blink::mojom::WebBluetoothRequestDeviceOptions::New(); | 427 blink::mojom::WebBluetoothRequestDeviceOptions::New(); |
| 399 blink::mojom::WebBluetoothScanFilterPtr scanFilter2 = | 428 blink::mojom::WebBluetoothScanFilterPtr scanFilter2 = |
| 400 blink::mojom::WebBluetoothScanFilter::New(); | 429 blink::mojom::WebBluetoothScanFilter::New(); |
| 401 | 430 |
| 402 scanFilter2->services.push_back(kHeartRateUUID); | 431 scanFilter2->services.push_back(GetHeartRateUUID()); |
| 403 options2->filters.push_back(std::move(scanFilter2)); | 432 options2->filters.push_back(std::move(scanFilter2)); |
| 404 | 433 |
| 405 options2->optional_services.push_back(kBloodPressureUUID); | 434 options2->optional_services.push_back(GetBloodPressureUUID()); |
| 406 | 435 |
| 407 // Add to map again. | 436 // Add to map again. |
| 408 const std::string device_id2 = | 437 const std::string device_id2 = |
| 409 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options2); | 438 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options2); |
| 410 | 439 |
| 411 EXPECT_EQ(device_id1, device_id2); | 440 EXPECT_EQ(device_id1, device_id2); |
| 412 | 441 |
| 413 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( | 442 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( |
| 414 kTestOrigin1, device_id1, kGlucoseUUID)); | 443 kTestOrigin1, device_id1, kGlucoseUUID)); |
| 415 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( | 444 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 426 const std::string& device_id = allowed_devices_map.AddDevice( | 455 const std::string& device_id = allowed_devices_map.AddDevice( |
| 427 kTestOrigin1, kDeviceAddress1, empty_options_); | 456 kTestOrigin1, kDeviceAddress1, empty_options_); |
| 428 | 457 |
| 429 EXPECT_TRUE(device_id.size() == 24) | 458 EXPECT_TRUE(device_id.size() == 24) |
| 430 << "Expected Lenghth of a 128bit string encoded to Base64."; | 459 << "Expected Lenghth of a 128bit string encoded to Base64."; |
| 431 EXPECT_TRUE((device_id[22] == '=') && (device_id[23] == '=')) | 460 EXPECT_TRUE((device_id[22] == '=') && (device_id[23] == '=')) |
| 432 << "Expected padding characters for a 128bit string encoded to Base64."; | 461 << "Expected padding characters for a 128bit string encoded to Base64."; |
| 433 } | 462 } |
| 434 | 463 |
| 435 } // namespace content | 464 } // namespace content |
| OLD | NEW |