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

Side by Side Diff: content/browser/bluetooth/bluetooth_allowed_devices_map_unittest.cc

Issue 2459523002: bluetooth: Return specific error if getPrimaryServices() is called without requesting access to any… (Closed)
Patch Set: Fix indent nits in tests Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
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 "content/common/bluetooth/web_bluetooth_device_id.h" 8 #include "content/common/bluetooth/web_bluetooth_device_id.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "url/gurl.h" 10 #include "url/gurl.h"
11 11
12 using device::BluetoothUUID; 12 using device::BluetoothUUID;
13 13
14 namespace content { 14 namespace content {
15 namespace { 15 namespace {
16 const url::Origin kTestOrigin1(GURL("https://www.example1.com")); 16 const url::Origin kTestOrigin1(GURL("https://www.example1.com"));
17 const url::Origin kTestOrigin2(GURL("https://www.example2.com")); 17 const url::Origin kTestOrigin2(GURL("https://www.example2.com"));
18 18
19 const std::string kDeviceAddress1 = "00:00:00"; 19 const std::string kDeviceAddress1 = "00:00:00";
20 const std::string kDeviceAddress2 = "11:11:11"; 20 const std::string kDeviceAddress2 = "11:11:11";
21 21
22 const std::string kDeviceName = "foo";
dcheng 2016/11/14 22:42:08 This violates the style guide: https://google.gith
ortuno 2016/11/14 22:57:27 nit: Please use a better name than "foo" e.g. "Tes
23
22 const char kGlucoseUUIDString[] = "00001808-0000-1000-8000-00805f9b34fb"; 24 const char kGlucoseUUIDString[] = "00001808-0000-1000-8000-00805f9b34fb";
23 const char kHeartRateUUIDString[] = "0000180d-0000-1000-8000-00805f9b34fb"; 25 const char kHeartRateUUIDString[] = "0000180d-0000-1000-8000-00805f9b34fb";
24 const char kBatteryServiceUUIDString[] = "0000180f-0000-1000-8000-00805f9b34fb"; 26 const char kBatteryServiceUUIDString[] = "0000180f-0000-1000-8000-00805f9b34fb";
25 const char kBloodPressureUUIDString[] = "00001813-0000-1000-8000-00805f9b34fb"; 27 const char kBloodPressureUUIDString[] = "00001813-0000-1000-8000-00805f9b34fb";
26 const char kCyclingPowerUUIDString[] = "00001818-0000-1000-8000-00805f9b34fb"; 28 const char kCyclingPowerUUIDString[] = "00001818-0000-1000-8000-00805f9b34fb";
27 const BluetoothUUID kGlucoseUUID(kGlucoseUUIDString); 29 const BluetoothUUID kGlucoseUUID(kGlucoseUUIDString);
28 const BluetoothUUID kHeartRateUUID(kHeartRateUUIDString); 30 const BluetoothUUID kHeartRateUUID(kHeartRateUUIDString);
29 const BluetoothUUID kBatteryServiceUUID(kBatteryServiceUUIDString); 31 const BluetoothUUID kBatteryServiceUUID(kBatteryServiceUUIDString);
30 const BluetoothUUID kBloodPressureUUID(kBloodPressureUUIDString); 32 const BluetoothUUID kBloodPressureUUID(kBloodPressureUUIDString);
31 const BluetoothUUID kCyclingPowerUUID(kCyclingPowerUUIDString); 33 const BluetoothUUID kCyclingPowerUUID(kCyclingPowerUUIDString);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 kTestOrigin1, kDeviceAddress1, empty_options_); 174 kTestOrigin1, kDeviceAddress1, empty_options_);
173 175
174 allowed_devices_map.RemoveDevice(kTestOrigin1, kDeviceAddress1); 176 allowed_devices_map.RemoveDevice(kTestOrigin1, kDeviceAddress1);
175 177
176 EXPECT_EQ(nullptr, 178 EXPECT_EQ(nullptr,
177 allowed_devices_map.GetDeviceId(kTestOrigin1, kDeviceAddress1)); 179 allowed_devices_map.GetDeviceId(kTestOrigin1, kDeviceAddress1));
178 EXPECT_EQ(base::EmptyString(), 180 EXPECT_EQ(base::EmptyString(),
179 allowed_devices_map.GetDeviceAddress(kTestOrigin1, device_id)); 181 allowed_devices_map.GetDeviceAddress(kTestOrigin1, device_id));
180 } 182 }
181 183
184 TEST_F(BluetoothAllowedDevicesMapTest, NoPermissionForAnyService) {
185 BluetoothAllowedDevicesMap allowed_devices_map;
186
187 // Setup device.
188 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options =
189 blink::mojom::WebBluetoothRequestDeviceOptions::New();
190 blink::mojom::WebBluetoothScanFilterPtr scanFilter =
191 blink::mojom::WebBluetoothScanFilter::New();
192
193 scanFilter->name = kDeviceName;
194 options->filters.push_back(scanFilter.Clone());
195
196 // Add to map.
197 const WebBluetoothDeviceId device_id =
198 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options);
199
200 // Try to access at least one service.
201 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessAtLeastOneService(
202 kTestOrigin1, device_id));
203 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService(
204 kTestOrigin1, device_id, kGlucoseUUID));
205 }
206
182 TEST_F(BluetoothAllowedDevicesMapTest, AllowedServices_OneOriginOneDevice) { 207 TEST_F(BluetoothAllowedDevicesMapTest, AllowedServices_OneOriginOneDevice) {
183 BluetoothAllowedDevicesMap allowed_devices_map; 208 BluetoothAllowedDevicesMap allowed_devices_map;
184 209
185 // Setup device. 210 // Setup device.
186 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options = 211 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options =
187 blink::mojom::WebBluetoothRequestDeviceOptions::New(); 212 blink::mojom::WebBluetoothRequestDeviceOptions::New();
188 blink::mojom::WebBluetoothScanFilterPtr scanFilter1 = 213 blink::mojom::WebBluetoothScanFilterPtr scanFilter1 =
189 blink::mojom::WebBluetoothScanFilter::New(); 214 blink::mojom::WebBluetoothScanFilter::New();
190 blink::mojom::WebBluetoothScanFilterPtr scanFilter2 = 215 blink::mojom::WebBluetoothScanFilterPtr scanFilter2 =
191 blink::mojom::WebBluetoothScanFilter::New(); 216 blink::mojom::WebBluetoothScanFilter::New();
192 217
193 scanFilter1->services.push_back(kGlucoseUUID); 218 scanFilter1->services.push_back(kGlucoseUUID);
194 options->filters.push_back(scanFilter1.Clone()); 219 options->filters.push_back(scanFilter1.Clone());
195 220
196 scanFilter2->services.push_back(kHeartRateUUID); 221 scanFilter2->services.push_back(kHeartRateUUID);
197 options->filters.push_back(scanFilter2.Clone()); 222 options->filters.push_back(scanFilter2.Clone());
198 223
199 options->optional_services.push_back(kBatteryServiceUUID); 224 options->optional_services.push_back(kBatteryServiceUUID);
200 options->optional_services.push_back(kHeartRateUUID); 225 options->optional_services.push_back(kHeartRateUUID);
201 226
202 // Add to map. 227 // Add to map.
203 const WebBluetoothDeviceId device_id1 = 228 const WebBluetoothDeviceId device_id1 =
204 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options); 229 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options);
205 230
206 // Access allowed services. 231 // Access allowed services.
232 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessAtLeastOneService(
233 kTestOrigin1, device_id1));
207 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( 234 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService(
208 kTestOrigin1, device_id1, kGlucoseUUID)); 235 kTestOrigin1, device_id1, kGlucoseUUID));
209 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( 236 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService(
210 kTestOrigin1, device_id1, kHeartRateUUID)); 237 kTestOrigin1, device_id1, kHeartRateUUID));
211 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( 238 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService(
212 kTestOrigin1, device_id1, kBatteryServiceUUID)); 239 kTestOrigin1, device_id1, kBatteryServiceUUID));
213 240
214 // Try to access a non-allowed service. 241 // Try to access a non-allowed service.
215 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService( 242 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService(
216 kTestOrigin1, device_id1, kBloodPressureUUID)); 243 kTestOrigin1, device_id1, kBloodPressureUUID));
217 244
218 // Try to access allowed services after removing device. 245 // Try to access allowed services after removing device.
219 allowed_devices_map.RemoveDevice(kTestOrigin1, kDeviceAddress1); 246 allowed_devices_map.RemoveDevice(kTestOrigin1, kDeviceAddress1);
220 247
248 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessAtLeastOneService(
249 kTestOrigin1, device_id1));
221 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService( 250 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService(
222 kTestOrigin1, device_id1, kGlucoseUUID)); 251 kTestOrigin1, device_id1, kGlucoseUUID));
223 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService( 252 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService(
224 kTestOrigin1, device_id1, kHeartRateUUID)); 253 kTestOrigin1, device_id1, kHeartRateUUID));
225 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService( 254 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService(
226 kTestOrigin1, device_id1, kBatteryServiceUUID)); 255 kTestOrigin1, device_id1, kBatteryServiceUUID));
227 256
228 // Add device back. 257 // Add device back.
229 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options2 = 258 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options2 =
230 blink::mojom::WebBluetoothRequestDeviceOptions::New(); 259 blink::mojom::WebBluetoothRequestDeviceOptions::New();
231 260
232 options2->filters.push_back(scanFilter1.Clone()); 261 options2->filters.push_back(scanFilter1.Clone());
233 options2->filters.push_back(scanFilter2.Clone()); 262 options2->filters.push_back(scanFilter2.Clone());
234 263
235 const WebBluetoothDeviceId device_id2 = 264 const WebBluetoothDeviceId device_id2 =
236 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options2); 265 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options2);
237 266
238 // Access allowed services. 267 // Access allowed services.
268 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessAtLeastOneService(
269 kTestOrigin1, device_id2));
239 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( 270 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService(
240 kTestOrigin1, device_id2, kGlucoseUUID)); 271 kTestOrigin1, device_id2, kGlucoseUUID));
241 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( 272 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService(
242 kTestOrigin1, device_id2, kHeartRateUUID)); 273 kTestOrigin1, device_id2, kHeartRateUUID));
243 274
244 // Try to access a non-allowed service. 275 // Try to access a non-allowed service.
245 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService( 276 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService(
246 kTestOrigin1, device_id2, kBatteryServiceUUID)); 277 kTestOrigin1, device_id2, kBatteryServiceUUID));
247 278
248 // Try to access services from old device. 279 // Try to access services from old device.
(...skipping 30 matching lines...) Expand all
279 310
280 options2->optional_services.push_back(kBloodPressureUUID); 311 options2->optional_services.push_back(kBloodPressureUUID);
281 312
282 // Add devices to map. 313 // Add devices to map.
283 const WebBluetoothDeviceId& device_id1 = 314 const WebBluetoothDeviceId& device_id1 =
284 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options1); 315 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options1);
285 const WebBluetoothDeviceId& device_id2 = 316 const WebBluetoothDeviceId& device_id2 =
286 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress2, options2); 317 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress2, options2);
287 318
288 // Access allowed services. 319 // Access allowed services.
320 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessAtLeastOneService(
321 kTestOrigin1, device_id1));
289 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( 322 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService(
290 kTestOrigin1, device_id1, kGlucoseUUID)); 323 kTestOrigin1, device_id1, kGlucoseUUID));
291 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( 324 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService(
292 kTestOrigin1, device_id1, kHeartRateUUID)); 325 kTestOrigin1, device_id1, kHeartRateUUID));
293 326
327 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessAtLeastOneService(
328 kTestOrigin1, device_id2));
294 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( 329 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService(
295 kTestOrigin1, device_id2, kBatteryServiceUUID)); 330 kTestOrigin1, device_id2, kBatteryServiceUUID));
296 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( 331 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService(
297 kTestOrigin1, device_id2, kBloodPressureUUID)); 332 kTestOrigin1, device_id2, kBloodPressureUUID));
298 333
299 // Try to access non-allowed services. 334 // Try to access non-allowed services.
300 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService( 335 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService(
301 kTestOrigin1, device_id1, kBatteryServiceUUID)); 336 kTestOrigin1, device_id1, kBatteryServiceUUID));
302 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService( 337 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService(
303 kTestOrigin1, device_id1, kBloodPressureUUID)); 338 kTestOrigin1, device_id1, kBloodPressureUUID));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 371
337 options2->optional_services.push_back(kBloodPressureUUID); 372 options2->optional_services.push_back(kBloodPressureUUID);
338 373
339 // Add devices to map. 374 // Add devices to map.
340 const WebBluetoothDeviceId& device_id1 = 375 const WebBluetoothDeviceId& device_id1 =
341 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options1); 376 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options1);
342 const WebBluetoothDeviceId& device_id2 = 377 const WebBluetoothDeviceId& device_id2 =
343 allowed_devices_map.AddDevice(kTestOrigin2, kDeviceAddress1, options2); 378 allowed_devices_map.AddDevice(kTestOrigin2, kDeviceAddress1, options2);
344 379
345 // Access allowed services. 380 // Access allowed services.
381 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessAtLeastOneService(
382 kTestOrigin1, device_id1));
346 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( 383 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService(
347 kTestOrigin1, device_id1, kGlucoseUUID)); 384 kTestOrigin1, device_id1, kGlucoseUUID));
348 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( 385 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService(
349 kTestOrigin1, device_id1, kHeartRateUUID)); 386 kTestOrigin1, device_id1, kHeartRateUUID));
350 387
388 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessAtLeastOneService(
389 kTestOrigin2, device_id2));
351 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( 390 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService(
352 kTestOrigin2, device_id2, kBatteryServiceUUID)); 391 kTestOrigin2, device_id2, kBatteryServiceUUID));
353 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( 392 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService(
354 kTestOrigin2, device_id2, kBloodPressureUUID)); 393 kTestOrigin2, device_id2, kBloodPressureUUID));
355 394
356 // Try to access non-allowed services. 395 // Try to access non-allowed services.
357 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService( 396 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService(
358 kTestOrigin1, device_id1, kBatteryServiceUUID)); 397 kTestOrigin1, device_id1, kBatteryServiceUUID));
359 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService( 398 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService(
360 kTestOrigin1, device_id1, kBloodPressureUUID)); 399 kTestOrigin1, device_id1, kBloodPressureUUID));
361 400
401 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessAtLeastOneService(
402 kTestOrigin1, device_id2));
362 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService( 403 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService(
363 kTestOrigin1, device_id2, kGlucoseUUID)); 404 kTestOrigin1, device_id2, kGlucoseUUID));
364 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService( 405 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService(
365 kTestOrigin1, device_id2, kHeartRateUUID)); 406 kTestOrigin1, device_id2, kHeartRateUUID));
366 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService( 407 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService(
367 kTestOrigin1, device_id2, kBatteryServiceUUID)); 408 kTestOrigin1, device_id2, kBatteryServiceUUID));
368 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService( 409 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService(
369 kTestOrigin1, device_id2, kBloodPressureUUID)); 410 kTestOrigin1, device_id2, kBloodPressureUUID));
370 411
371 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService( 412 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService(
372 kTestOrigin2, device_id2, kGlucoseUUID)); 413 kTestOrigin2, device_id2, kGlucoseUUID));
373 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService( 414 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService(
374 kTestOrigin2, device_id2, kHeartRateUUID)); 415 kTestOrigin2, device_id2, kHeartRateUUID));
375 416
417 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessAtLeastOneService(
418 kTestOrigin2, device_id1));
376 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService( 419 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService(
377 kTestOrigin2, device_id1, kGlucoseUUID)); 420 kTestOrigin2, device_id1, kGlucoseUUID));
378 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService( 421 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService(
379 kTestOrigin2, device_id1, kHeartRateUUID)); 422 kTestOrigin2, device_id1, kHeartRateUUID));
380 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService( 423 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService(
381 kTestOrigin2, device_id1, kBatteryServiceUUID)); 424 kTestOrigin2, device_id1, kBatteryServiceUUID));
382 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService( 425 EXPECT_FALSE(allowed_devices_map.IsOriginAllowedToAccessService(
383 kTestOrigin2, device_id1, kBloodPressureUUID)); 426 kTestOrigin2, device_id1, kBloodPressureUUID));
384 } 427 }
385 428
(...skipping 25 matching lines...) Expand all
411 options2->filters.push_back(std::move(scanFilter2)); 454 options2->filters.push_back(std::move(scanFilter2));
412 455
413 options2->optional_services.push_back(kBloodPressureUUID); 456 options2->optional_services.push_back(kBloodPressureUUID);
414 457
415 // Add to map again. 458 // Add to map again.
416 const WebBluetoothDeviceId device_id2 = 459 const WebBluetoothDeviceId device_id2 =
417 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options2); 460 allowed_devices_map.AddDevice(kTestOrigin1, kDeviceAddress1, options2);
418 461
419 EXPECT_EQ(device_id1, device_id2); 462 EXPECT_EQ(device_id1, device_id2);
420 463
464 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessAtLeastOneService(
465 kTestOrigin1, device_id1));
421 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( 466 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService(
422 kTestOrigin1, device_id1, kGlucoseUUID)); 467 kTestOrigin1, device_id1, kGlucoseUUID));
423 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( 468 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService(
424 kTestOrigin1, device_id1, kBatteryServiceUUID)); 469 kTestOrigin1, device_id1, kBatteryServiceUUID));
425 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( 470 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService(
426 kTestOrigin1, device_id1, kHeartRateUUID)); 471 kTestOrigin1, device_id1, kHeartRateUUID));
427 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService( 472 EXPECT_TRUE(allowed_devices_map.IsOriginAllowedToAccessService(
428 kTestOrigin1, device_id1, kBloodPressureUUID)); 473 kTestOrigin1, device_id1, kBloodPressureUUID));
429 } 474 }
430 475
431 TEST_F(BluetoothAllowedDevicesMapTest, CorrectIdFormat) { 476 TEST_F(BluetoothAllowedDevicesMapTest, CorrectIdFormat) {
432 BluetoothAllowedDevicesMap allowed_devices_map; 477 BluetoothAllowedDevicesMap allowed_devices_map;
433 478
434 const WebBluetoothDeviceId& device_id = allowed_devices_map.AddDevice( 479 const WebBluetoothDeviceId& device_id = allowed_devices_map.AddDevice(
435 kTestOrigin1, kDeviceAddress1, empty_options_); 480 kTestOrigin1, kDeviceAddress1, empty_options_);
436 481
437 EXPECT_TRUE(WebBluetoothDeviceId::IsValid(device_id.str())); 482 EXPECT_TRUE(WebBluetoothDeviceId::IsValid(device_id.str()));
438 } 483 }
439 484
440 } // namespace content 485 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/bluetooth/bluetooth_allowed_devices_map.cc ('k') | content/browser/bluetooth/web_bluetooth_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698