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

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

Issue 2188373002: DO NOT SUBMIT bluetooth-fuzzer: Draft fuzzer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-catch-and-connect
Patch Set: 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.cc
diff --git a/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc b/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc
index 930f9dd4c454c0c53cf6a8ea676639e09c304f95..4065b558589b93f5bb0f1a641ade6adfb867fa67 100644
--- a/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc
+++ b/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc
@@ -501,8 +501,15 @@ scoped_refptr<NiceMockBluetoothAdapter>
LayoutTestBluetoothAdapterProvider::GetDisconnectingHeartRateAdapter() {
scoped_refptr<NiceMockBluetoothAdapter> adapter(GetEmptyAdapter());
NiceMockBluetoothAdapter* adapter_ptr = adapter.get();
+
+ BluetoothDevice::UUIDList uuids;
+ uuids.push_back(BluetoothUUID(kGenericAccessServiceUUID));
+ uuids.push_back(BluetoothUUID(kHeartRateServiceUUID));
+ uuids.push_back(BluetoothUUID(kRequestDisconnectionServiceUUID));
+
std::unique_ptr<NiceMockBluetoothDevice> device(
- GetHeartRateDevice(adapter.get()));
+ GetConnectableDevice(adapter.get(), "Disconnecting Device", uuids));
+
NiceMockBluetoothDevice* device_ptr = device.get();
// TODO(ortuno): Implement the rest of the service's characteristics
@@ -869,16 +876,6 @@ LayoutTestBluetoothAdapterProvider::GetGenericAccessService(
ON_CALL(*peripheral_privacy_flag, ReadRemoteCharacteristic(_, _))
.WillByDefault(RunCallback<0>(value));
- // Crash if WriteRemoteCharacteristic called. Not using GoogleMock's Expect
- // because this is used in layout tests that may not report a mock
- // expectation error correctly as a layout test failure.
- ON_CALL(*peripheral_privacy_flag, WriteRemoteCharacteristic(_, _, _))
- .WillByDefault(
- Invoke([](const std::vector<uint8_t>&, const base::Closure&,
- const BluetoothRemoteGattCharacteristic::ErrorCallback&) {
- NOTREACHED();
- }));
-
generic_access->AddMockCharacteristic(std::move(peripheral_privacy_flag));
}
@@ -976,9 +973,26 @@ LayoutTestBluetoothAdapterProvider::GetBaseGATTCharacteristic(
MockBluetoothGattService* service,
const std::string& uuid,
BluetoothRemoteGattCharacteristic::Properties properties) {
- return base::WrapUnique(new NiceMockBluetoothGattCharacteristic(
- service, identifier, BluetoothUUID(uuid), false /* is_local */,
- properties, NULL /* permissions */));
+ std::unique_ptr<NiceMockBluetoothGattCharacteristic> characteristic(
+ new NiceMockBluetoothGattCharacteristic(
+ service, identifier, BluetoothUUID(uuid), false /* is_local */,
+ properties, NULL /* permissions */));
+
+ device::BluetoothGattService::GattErrorCode default_error =
+ device::BluetoothGattService::GATT_ERROR_NOT_SUPPORTED;
+
+ // Default Write response.
+ ON_CALL(*characteristic, WriteRemoteCharacteristic(_, _, _))
+ .WillByDefault(RunCallback<2>(default_error));
+
+ // Read response.
+ ON_CALL(*characteristic, ReadRemoteCharacteristic(_, _))
+ .WillByDefault(RunCallback<1>(default_error));
+
+ ON_CALL(*characteristic, StartNotifySession(_, _))
+ .WillByDefault(RunCallback<1>(default_error));
+
+ return characteristic;
}
// static

Powered by Google App Engine
This is Rietveld 408576698