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

Side by Side 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, 4 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 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 #ifndef CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVIDER _H_ 5 #ifndef CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVIDER _H_
6 #define CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVIDER _H_ 6 #define CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVIDER _H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // - Generic Access UUID (0x1800) 175 // - Generic Access UUID (0x1800)
176 // - Heart Rate UUID (0x180d) 176 // - Heart Rate UUID (0x180d)
177 // - Services: 177 // - Services:
178 // - Generic Access Service - Characteristics as described in 178 // - Generic Access Service - Characteristics as described in
179 // GetGenericAccessService. 179 // GetGenericAccessService.
180 // - Heart Rate Service - Characteristics as described in 180 // - Heart Rate Service - Characteristics as described in
181 // GetHeartRateService. 181 // GetHeartRateService.
182 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> 182 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>>
183 GetHeartRateAdapter(); 183 GetHeartRateAdapter();
184 184
185 // |GetEmptyNameHeartRateAdapter|
186 // Inherits from |EmptyAdapter|
187 // Internal Structure:
188 // - Heart Rate Device
189 // - UUIDs:
190 // - Generic Access UUID (0x1800)
191 // - Heart Rate UUID (0x180d)
192 // - Services:
193 // - Generic Access Service - Characteristics as described in
194 // GetGenericAccessService.
195 // - gap.device_name returns an empty string.
196 // - Heart Rate Service - Characteristics as described in
197 // GetHeartRateService.
198 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>>
199 GetEmptyNameHeartRateAdapter();
200
201 // |GetNoNameHeartRateAdapter|
202 // Inherits from |EmptyAdapter|
203 // Internal Structure:
204 // - Heart Rate Device
205 // - GetName returns base::null_opt.
206 // - UUIDs:
207 // - Generic Access UUID (0x1800)
208 // - Heart Rate UUID (0x180d)
209 // - Services:
210 // - Generic Access Service - Characteristics as described in
211 // GetGenericAccessService.
212 // - gap.device_name returns an empty string.
213 // - Heart Rate Service - Characteristics as described in
214 // GetHeartRateService.
215 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>>
216 GetNoNameHeartRateAdapter();
217
185 // |TwoHeartRateServicesAdapter| 218 // |TwoHeartRateServicesAdapter|
186 // Inherits from |EmptyAdapter| 219 // Inherits from |EmptyAdapter|
187 // Internal Structure: 220 // Internal Structure:
188 // - Heart Rate Device 221 // - Heart Rate Device
189 // - UUIDs: 222 // - UUIDs:
190 // - Generic Access UUID (0x1800) 223 // - Generic Access UUID (0x1800)
191 // - Heart Rate UUID (0x180d) 224 // - Heart Rate UUID (0x180d)
192 // - Heart Rate UUID (0x180d) 225 // - Heart Rate UUID (0x180d)
193 // - Services: 226 // - Services:
194 // - Generic Access Service - Characteristics as described in 227 // - Generic Access Service - Characteristics as described in
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 // Returns: address 397 // Returns: address
365 // - GetName: 398 // - GetName:
366 // Returns: device_name. 399 // Returns: device_name.
367 // - IsPaired: 400 // - IsPaired:
368 // Returns true. 401 // Returns true.
369 // - ConnectGatt: 402 // - ConnectGatt:
370 // Calls error callback with 403 // Calls error callback with
371 // BluetoothDevice::ConnectErrorCode::ERROR_UNSUPPORTED_DEVICE. 404 // BluetoothDevice::ConnectErrorCode::ERROR_UNSUPPORTED_DEVICE.
372 static std::unique_ptr<testing::NiceMock<device::MockBluetoothDevice>> 405 static std::unique_ptr<testing::NiceMock<device::MockBluetoothDevice>>
373 GetBaseDevice(device::MockBluetoothAdapter* adapter, 406 GetBaseDevice(device::MockBluetoothAdapter* adapter,
374 const std::string& device_name = "Base Device", 407 const base::Optional<std::string>& device_name =
408 base::Optional<std::string>("Base Device"),
375 device::BluetoothDevice::UUIDList uuids = 409 device::BluetoothDevice::UUIDList uuids =
376 device::BluetoothDevice::UUIDList(), 410 device::BluetoothDevice::UUIDList(),
377 const std::string& address = "00:00:00:00:00:00"); 411 const std::string& address = "00:00:00:00:00:00");
412 // Version without base::optional parameters, for simpler call sites:
413 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.
414 GetBaseDevice(device::MockBluetoothAdapter* adapter,
415 const std::string& device_name,
416 device::BluetoothDevice::UUIDList uuids =
417 device::BluetoothDevice::UUIDList(),
418 const std::string& address = "00:00:00:00:00:00") {
419 return GetBaseDevice(adapter, base::make_optional(device_name), uuids,
420 address);
421 }
378 422
379 // |BatteryDevice| 423 // |BatteryDevice|
380 // Inherits from |BaseDevice|(adapter, "Battery Device", uuids, 424 // Inherits from |BaseDevice|(adapter, "Battery Device", uuids,
381 // "00:00:00:00:00:01") 425 // "00:00:00:00:00:01")
382 // UUIDs added: 426 // UUIDs added:
383 // - Battery Service UUID (0x180F) 427 // - Battery Service UUID (0x180F)
384 // Services added: 428 // Services added:
385 // None. 429 // None.
386 static std::unique_ptr<testing::NiceMock<device::MockBluetoothDevice>> 430 static std::unique_ptr<testing::NiceMock<device::MockBluetoothDevice>>
387 GetBatteryDevice(device::MockBluetoothAdapter* adapter); 431 GetBatteryDevice(device::MockBluetoothAdapter* adapter);
(...skipping 15 matching lines...) Expand all
403 // UUIDs added: 447 // UUIDs added:
404 // None. 448 // None.
405 // Services added: 449 // Services added:
406 // None. 450 // None.
407 // Mock Functions: 451 // Mock Functions:
408 // - CreateGattConnection: 452 // - CreateGattConnection:
409 // - Run success callback with BaseGATTConnection 453 // - Run success callback with BaseGATTConnection
410 static std::unique_ptr<testing::NiceMock<device::MockBluetoothDevice>> 454 static std::unique_ptr<testing::NiceMock<device::MockBluetoothDevice>>
411 GetConnectableDevice( 455 GetConnectableDevice(
412 device::MockBluetoothAdapter* adapter, 456 device::MockBluetoothAdapter* adapter,
413 const std::string& device_name = "Connectable Device", 457 const base::Optional<std::string>& device_name =
458 base::Optional<std::string>("Connectable Device"),
414 device::BluetoothDevice::UUIDList = device::BluetoothDevice::UUIDList(), 459 device::BluetoothDevice::UUIDList = device::BluetoothDevice::UUIDList(),
415 const std::string& address = "00:00:00:00:00:00"); 460 const std::string& address = "00:00:00:00:00:00");
461 // Version without base::optional parameters, for simpler call sites:
462 static std::unique_ptr<testing::NiceMock<device::MockBluetoothDevice>>
463 GetConnectableDevice(device::MockBluetoothAdapter* adapter,
464 const std::string& device_name,
465 device::BluetoothDevice::UUIDList uuids =
466 device::BluetoothDevice::UUIDList(),
467 const std::string& address = "00:00:00:00:00:00") {
468 return GetConnectableDevice(adapter, base::make_optional(device_name),
469 uuids, address);
470 }
416 471
417 // |UnconnectableDevice| 472 // |UnconnectableDevice|
418 // Inherits from |BaseDevice|(adapter, device_name) 473 // Inherits from |BaseDevice|(adapter, device_name)
419 // UUIDs added: 474 // UUIDs added:
420 // - errorUUID(error_code) 475 // - errorUUID(error_code)
421 // Services added: 476 // Services added:
422 // None. 477 // None.
423 // Mock Functions: 478 // Mock Functions:
424 // - CreateGATTConnection: 479 // - CreateGATTConnection:
425 // - Run error callback with error_type 480 // - Run error callback with error_type
426 static std::unique_ptr<testing::NiceMock<device::MockBluetoothDevice>> 481 static std::unique_ptr<testing::NiceMock<device::MockBluetoothDevice>>
427 GetUnconnectableDevice( 482 GetUnconnectableDevice(
428 device::MockBluetoothAdapter* adapter, 483 device::MockBluetoothAdapter* adapter,
429 device::BluetoothDevice::ConnectErrorCode error_code, 484 device::BluetoothDevice::ConnectErrorCode error_code,
430 const std::string& device_name = "Unconnectable Device"); 485 const std::string& device_name = "Unconnectable Device");
431 486
432 // |HeartRateDevice| 487 // |HeartRateDevice|
433 // Inherits from |ConnectableDevice|(adapter, "Heart Rate Device", uuids) 488 // Inherits from |ConnectableDevice|(adapter, "Heart Rate Device", uuids)
434 // UUIDs added: 489 // UUIDs added:
435 // - Generic Access (0x1800) 490 // - Generic Access (0x1800)
436 // - Heart Rate UUID (0x180D) 491 // - Heart Rate UUID (0x180D)
437 // Services added: 492 // Services added:
438 // None. Each user of the HeartRateDevice is in charge of adding the 493 // None. Each user of the HeartRateDevice is in charge of adding the
439 // relevant services, characteristics and descriptors. 494 // relevant services, characteristics and descriptors.
440 static std::unique_ptr<testing::NiceMock<device::MockBluetoothDevice>> 495 static std::unique_ptr<testing::NiceMock<device::MockBluetoothDevice>>
441 GetHeartRateDevice(device::MockBluetoothAdapter* adapter); 496 GetHeartRateDevice(device::MockBluetoothAdapter* adapter,
497 const base::Optional<std::string>& device_name =
498 base::Optional<std::string>("Heart Rate Device"));
442 499
443 // Services 500 // Services
444 501
445 // |BaseGATTService|(identifier, device, uuid) 502 // |BaseGATTService|(identifier, device, uuid)
446 // Characteristics added: 503 // Characteristics added:
447 // None. 504 // None.
448 // Mock Functions: 505 // Mock Functions:
449 // - GetCharacteristics: 506 // - GetCharacteristics:
450 // Returns a list with all the characteristics added to the service 507 // Returns a list with all the characteristics added to the service
451 // - GetCharacteristic: 508 // - GetCharacteristic:
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 680
624 // Function to turn an integer into an MAC address of the form 681 // Function to turn an integer into an MAC address of the form
625 // XX:XX:XX:XX:XX:XX. For example makeMACAddress(0xdeadbeef) 682 // XX:XX:XX:XX:XX:XX. For example makeMACAddress(0xdeadbeef)
626 // returns "00:00:DE:AD:BE:EF". 683 // returns "00:00:DE:AD:BE:EF".
627 static std::string makeMACAddress(uint64_t addr); 684 static std::string makeMACAddress(uint64_t addr);
628 }; 685 };
629 686
630 } // namespace content 687 } // namespace content
631 688
632 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVI DER_H_ 689 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVI DER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698